We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

worksheet.Cells.Columns.Count reporting incorrect value


I am trying to use the worksheet.Cells.UnhideColumns(0, worksheet.Cells.Columns.Count, -1), but it is not working since I have 24 columns, yet worksheet.Cells.Columns.Count is reporting 5. I have code with comments, Expected.pdf, output.pdf and the sheet I am testing with in attached zip.

Charlestest.zip (179.7 KB)

We were able to observe the issue but we need to look into it more. We have logged the issue in our database for investigation and for a fix. Once, we will have some news for you, we will update you in this topic.

This issue has been logged as

CELLSNET-46702 - Wrong number of columns returned while using Worksheet.Cells.Columns.Count


We evaluated your issue further. Well, you are not using correct APIs.
Please change your code as following:
Sample code:

Worksheet worksheet = workbook.Worksheets[0];
worksheet.Cells.UnhideRows(0, worksheet.Cells.MaxRow + 1, -1);
// This does not work, due to columns count showing 5 vs 24
worksheet.Cells.UnhideColumns(0, worksheet.Cells.MaxColumn + 1, -1);

Let us know if you still find the issue.

Thank you, that worked.


Good to know that your issue is sorted out by changing your code as suggested. Feel free to contact us any time if you need further help or have some other issue or queries, we will be happy to assist you soon.