How do i get the index of the last column when reading a xlsx
file using the Apache POI API?
There's a getLastRowNum
method, but I can't find nothing related to the number of columns...
EDIT:
I'm dealing with XLSX
files
Locate the last cell that contains data or formatting on a worksheet. To locate the last cell that contains data or formatting, click anywhere in the worksheet, and then press CTRL+END.
ADDRESS function The maximum number of columns in an Excel worksheet is 16,384, so the final column in a worksheet is "XFD".
Step 1: Add a shape (Find Last Row/Column/Cell) on your worksheet. Step 2: Right-click on “Find Last Row/Column/Cell” and “Assign Macro..” Step 5: Click “Find Last Row/Column/Cell” to execute the VBA code.
I think you'll have to iterate through the rows and check HSSFRow.getLastCellNum()
on each of them.
Check each Row and call Row.getLastCellNum()
the max cell number is the last column number.
Row r = sheet.getRow(rowNum);
int maxCell= r.getLastCellNum();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With