I have defined a named range in Excel (“therange”). The Range includes a hidden row (line 8).
This is what I need to achieve:
· Get a handle on the named range using GetNamedRangesAndTables();
· Iterate through all cells in the range and determine if the cell is visible (e.g. is the according row or column hidden?)
Please see attached Excel-File as an example
How can I achieve that?
Thanks for the template file.
See the sample code below that denotes how to determine if a row is hidden in a range. I have used your template file in the code. You may refer to it and may add or update code accordingly for your needs:
// Open Excel file.
Workbook workbook = new Workbook(“e:\test2\HiddenRow.xlsx”);
//If you just want to know any row in referred range is hidden, you may determine as following:
Range range = workbook.Worksheets.Names[“therange”].GetRange();
if (range != null)
MessageBox.Show(“Worksheet is not visible.”);
Cells cells = range.Worksheet.Cells;
for (int i = range.FirstRow; i < (range.RowCount + range.FirstRow) ; i++)
Console.WriteLine(“Row " + (cells.Rows[i].Index +1).ToString() + " is hidden”);
//Similarly you may try to evaluate if any column is hidden
//…Your code goes here.
Hope, this helps a bit.
Good to know that it figures out your issue now. 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.