Hi,
Hi Michael,
book.Worksheets returns a collection of worksheets. This collection is a zore-based index. If you have only one sheet in the Excel workbook, then you will get empty at index 1.
If it needs more explanation, please feel free to reach us with more detail also share your Excel file with us in order to get complete picture of the issue.
Thanks,
Hi Salman,
Hi Salman,
Hi,
Well, your code (Worksheet.Cells.Ranges will extract the Workbook specific named ranges and not Worksheet specific named ranges) will work for Workbook(Global) named ranges. You may use Worksheets.GetNamedRanges() to extract both types of ranges.
See the sample code:
Range[] ranges = book.Worksheets.GetNamedRanges();
for (int i = 0; i < ranges.Length; i++)
{
MessageBox.Show(ranges[i].Name);
MessageBox.Show(ranges[i].Worksheet.Name);
}
For further reference on how to create both types of ranges, see the topic:
http://www.aspose.com/documentation/.net-components/aspose.cells-for-.net/create-workbook-global-worksheet-scoped-named-ranges.html
thank you.
Hi Amjad,