Hi,
I am trying to get a range by its name but it returns nulll. The issue is not with all the excel sheets but with the attached excel sheet, I have checked the sheet and it defines the ranges properly and it works fine with the excelInterop library in the code. Not sure why its an issue with aspose.
@hi.shobhit82,
I have opened the Excel file in MS Excel but could not observe the named range “TableRange” as shown in the following image. Could you please verify if the target named range exists in the workbook or not?
Please go to the tab “Formulas” --> then click on “Name Manager” (in the section defined names).You will find the list of all the ranges present within the excel sheet. Refer image below.
Also, you can use the API method to fetch all the names ranges present in the excel via the code, but it gives all the ranges all at once, i am surprised why names range method doesn’t work.
var allRanges = renderedSheet.Workbook.Worksheets.GetNamedRanges();
@hi.shobhit82,
Thank you for providing more details. This issue is reproduced here and logged in our database for further investigation. You will be notified here once any update is ready for sharing.
This issue is logged as: CELLSNET-48546 - GetRangeByName returning null
But aren’t the named ranges valid for a workbook and we can’t have a range with the same name within a workbook ?
Also, what I don’t understand is that I why the same code of getting the named range does not fail with another workbook (attached) where the range is again present in another worksheet.
It has a reason. Book1.xlsx has “TableRange” range whose scope is “Workbook” level. Whereas, your previous file (you attached in the first post) has “TableRange” that has “Worksheet” level scope, so you have to access it with respect it its worksheet (“Rendering” in your case). See the screenshots of both files taken in MS Excel when opening into MS Excel manually. sc_shot1.png (68.7 KB) sc_shot2.png (70.9 KB)