How to enumerate the columns to find hidden

Hi there, I tried to use a for loop from 0 to sheet.cells.columns.count to check if the column width is 0.0 in order to find any hidden columns. However, the columns.count is always 1, and the rows.count is always 18.

for (int i = 0; i < columnCount; i++){

double width = sheet.Cells.GetColumnWidth(i);

if (width == 0.0) {//MarkColumnAsHidden();}

}

When I open Excel I see columns A thru V (22 columns) and rows are usually 50 or 100, but if I want to make sure that I am checking all of my available cols and rows, how can I enumerate with either a GetNext() or use a maximum constant using (For i to MaxColumns) types of Properties.

Thanks,

Karen Schmidt

Hi Karen,

Thank you for considering Aspose.

Well, Cells.Columns.Count property would give you columns count excluding the columns with standard (default) settings / formatting. For your information, the Rows.Count and Columns.Count are mainly useful if you want to retrieve the number of rows / columns which are initialized / used in the worksheet.

Please use Cells.MaxColumn and Cells.MaxRow if you need to get the farthest cell with data or formatting and style applied and use Cells.MaxDataColumn and Cells.MaxDataRow attributes to get the farthest column and row indexes containing data only.
you may change you code, e.g

int maxcol = sheet.Cells.MaxColumn;
for (int i = 0; i < maxcol; i++){

double width = sheet.Cells.GetColumnWidth(i);

if (width == 0.0) {//MarkColumnAsHidden();}

}



Thank you.