Liste déroulante Excel utilisant le POI Apache
J'ai besoin de créer une liste déroulante dans excel fichier à l'aide d'Apache POI. et je suis capable de le faire Mais
Je ne suis pas capable de faire le premier élément dans la liste déroulante en tant que par défaut de l'Élément.
public class sd {
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
DataValidation dataValidation = null;
DataValidationConstraint constraint = null;
DataValidationHelper validationHelper = null;
XSSFWorkbook wb = new XSSFWorkbook();
XSSFSheet sheet1=(XSSFSheet) wb.createSheet("sheet1");
validationHelper=new XSSFDataValidationHelper(sheet1);
CellRangeAddressList addressList = new CellRangeAddressList(0,5,0,0);
constraint =validationHelper.createExplicitListConstraint(new String[]{"SELECT","10", "20", "30"});
dataValidation = validationHelper.createValidation(constraint, addressList);
dataValidation.setSuppressDropDownArrow(true);
sheet1.addValidationData(dataValidation);
FileOutputStream fileOut = new FileOutputStream("c:\\temp\\vineet.xlsx");
wb.write(fileOut);
fileOut.close();
}
}
source d'informationauteur Vineet
Vous devez vous connecter pour publier un commentaire.
définir une valeur par défaut, juste setCellValue("first_item_value");
J'ai fait comme face au même problème.
Voici mon code: