How can we retrieve the worksheet names using Aspose.Cells. I have attached below a excel sheet which has three sheets with the names "Test1", "Test2" and "Test3". I was trying the following code snippet -
workbook = new Workbook();
workbook.Open(ExcelFileName);
string[] sNames = new string[workbook.Worksheets.Count];
Names worksheetNames = workbook.Worksheets.Names;
foreach (Name name in worksheetNames)
{
sNames[loop++] = name.Text;
}
return sNames;
However the collection worksheetNames did not have any element when I did a quickwatch and so it did not enter the for each loop.
Well, I think you slightly misunderstood Worksheets.Names. Basically it is used to get the collection of defined names (Named ranges defined in the worksheets) in a workbook. You may use Worksheet.Name property to get a worksheet name.
If you want to get each worksheet name only, you can modify your code a bit.
workbook = new Workbook();
workbook.Open(ExcelFileName);
string[] sNames = new string[workbook.Worksheets.Count];
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.