Inconsistent Row/Column Count?

Hi


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();

I’ve attached the two XLS files

Thanks

Hi,


Thanks for the template files and sample code.

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.

Thank you.

Hi


Thanks for the response, is the RowCollection/ColumnCollection.getCount() intended to return data that is considered ‘unreliable’.

If so, are these methods intended to be deprecated

Thanks

Hi,


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.