I'm getting an error reading .xlsx files with large numbers of columns.
PROBLEM: the cells are not being read in the correct order. I'm not sure if
it is pilot error or an actual bug. I'm using POI version 3.5-beta5 and saw
on the POI list of changes the following fix for version 3.5-beta5: "Fixed
XSSFCell to properly handle cell references with column numbers up to
XFD(POI-DEVELOPERS)". It seems related, but since I'm using that version it
should be fixed. QUESTION: can you look at the following snippet and let me
know if I am doing something wrong? The snippet simply prints each cell in
the first row to system.out.
try {
File xlsxFile = new File("xlsx_loader_test.xlsx");
Workbook wb = new XSSFWorkbook(xlsxFile.getAbsolutePath());
Sheet sheet = wb.getSheet("Sheet1");
Row row = sheet.getRow(0);
int i = 0;
for (Cell cell : row) {
System.out.println("Column " + ++i + " value: " + cell.toString());
}
} catch (Exception e) {
e.printStackTrace();
}
TO REPRODUCE THE ERROR:
1. Create a spreadsheet with the name "xlsx_loader_test.xlsx".
2. In the worksheet "Sheet1" put in the first row the following values:
COLUMN1, COLUMN2, ..., COLUMN2500. Specifically, you will have "COLUMN1" in
A1 up to "COLUMN2500" in CRD1
3. Cut and paste the snippet above into Java class and run it against the
spreadsheet.
The results I received produced only 702 columns. Below is a small portion
of it where the columns are out of order. It starts at column 27:
Column 24 value: COLUMN24
Column 25 value: COLUMN25
Column 26 value: COLUMN26
Column 27 value: COLUMN728
Column 28 value: COLUMN754
Column 29 value: COLUMN780
Column 30 value: COLUMN806
Column 31 value: COLUMN832