Free Support Forum - aspose.com

Hidden columns and rows

I need to do some preliminary checking on worksheets before certain formatting is applied, one of them being makin gsure there are no hidden columns or rows.

How do I check to see if a column/row is hidden or not?

You can use Cells.GetRowHeight and Cells.GetColumnWidth method to get row height and column width values. The value will be 0 if the row/column is hidden.

Thanks, but now I have another problem.

I’ve attached the test file I’m using, with one hidden column. However, as I will not know the exact number of columns before a user submits the file, I’m using the following to get the number of columns:

For col = 0 To oSheet.Cells.Columns.Count - 1
If oSheet.Cells.GetColumnWidth(col) = 0.0 Then Return True
Next

As you can see the tets file has 5 columns, but oSheet.Cells.Columns.Count is returning a value of 1 (2 columns, not 5).

Any ideas?

Columns class only contains columns with settings different with default setting.

Please try:

For col = 0 To oSheet.Cells.MaxColumn
If oSheet.Cells.GetColumnWidth(col) = 0.0 Then Return True
Next

Thanks, but now I have another problem.

Using the attached test file, I applied some formatting to the first sheet and left the second sheet with all defaults. Now my code is not picking up any rows with a height of 0.0. --> all rows are showing a height as if not hidden.

Any ideas?

Which version are you using? Please try this latest fix.