I want to make the cell offer some options for the user to choose just like
excel 2003.
I tried with POI3.7. But the produced excel2007 file is wrong, it can not be
opened.
Here are the core code I write:
public static void write(OutputStream outputStream) throws
IOException, ClassNotFoundException
{
XSSFWorkbook workbook = new XSSFWorkbook();
XSSFSheet sheet = workbook.createSheet("sheet1");
String[] strs = new String[]{"A", "B", "C"};
CellRangeAddressList regions = new CellRangeAddressList(0, 9, 0, 0);
XSSFDataValidationConstraint constraint = new XSSFDataValidationConstraint
(strs);
CTDataValidation ct = CTDataValidation.Factory.newInstance();
//while in 2007 the method is changed not like the 2003 I do not know if
the method I invoke is right.
XSSFDataValidation dataValidation = new XSSFDataValidation(constraint,
regions, ct);
sheet.addValidationData(dataValidation);
workbook.write(outputStream);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]