I have two files. One has 10 rows with 5 hidden rows. The other has 10 columns with 5 hidden columns.
When I get the total row count of the file with the hidden rows, the result is 10. When I get the total column count on the file with the hidden columns I get 5.
Which is the expected behavior?
Here is the code I’m using
The hidden row file: -
InputStream inputStream = new ByteArrayInputStream(testUill.readInFile(fileName));
Workbook workbook = new Workbook(inputStream, new LoadOptions())
int rows = workbook.getWorksheets().get(0).getCells().getRows().getCount();
The hidden column file:
InputStream inputStream = new ByteArrayInputStream(testUill.readInFile(fileName));
Workbook workbook = new Workbook(inputStream, new LoadOptions())
int columns = workbook.getWorksheets().get(0).getCells().getColumns().getCount();
Well, RowCollection/ColumnCollection.getCount() would give you total number of rows/columns which are initialized only, so it won’t be always reliable. I think you should use Cells.getMaxRow/getMaxDataRow and Cells.getMaxColumn/getMaxDataColumns methods to get the farthest (last) row/column indices, see the sample code segment for your reference:
e.g
Sample code:
Workbook workbook = new Workbook(“UnhideRows.xls”, new LoadOptions());
//Get the farthest (last) row’s index (zero-based) which contains data or formattings.
int lastRowIndex = workbook.getWorksheets().get(0).getCells().getMaxRow();//9 -Ok
workbook = new Workbook(“UnhideColumns.xls”, new LoadOptions());
//Get the farthest (last) column’s index (zero-based) which contains data or formattings.
int lastColIndex = workbook.getWorksheets().get(0).getCells().getMaxColumn(); //9 -Ok
Let us know if you still have any issue or confusion.
Well, the return value of RowCollection/ColumnCollection.getCount() is not intended but it returns number of rows or columns which are initialized only. Anyways, you may use the suggested attributes instead.
Thank you.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
Enables storage, such as cookies, related to analytics.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.