Hi there, we’re starting to use the Aspose.Cells named range API in order to find content that has been entered into Excel files. We’re currently working with Aspose.Cells 4.4.3.17, so we’re a little out of date. One curious thing that is happening with some Excel files is that the following API sample produces “extra” items in the Names collection:
I have this bound to a repeater. The repeater displays each Name instance’s RefersTo property and Text property. Some items appear to be duplicates in the rendered repeater. I.e. a partial copy and paste from the resultant rendered table of the repeater shows:
#REF!$B$186
access1
Yes
Starts at: R185/C1, Size: 1R x 1C
0/0 Content:[[similar]]
Click to View Range
=#REF!$B$186
access1
Yes
Starts at: R185/C1, Size: 1R x 1C
0/0 Content:[[similar]]
Click to View Range
=#REF!$B$186
access1
Yes
Starts at: R185/C1, Size: 1R x 1C
0/0 Content:[[similar]]
Click to View Range
=#REF!$B$186
access1
Yes
Starts at: R185/C1, Size: 1R x 1C
0/0 Content:[[similar]]
Column 1 is the RefersTo property. Column 2 is the Text property. Before going further in analyzing the issue, do you know if this is a known issue with the current Aspose.Cells API, or if it was a known issue with our particular version of Aspose.Cells?
It does not seem to be happening with all Excel files that I am evaluating. Some seem to not have duplicate entries in the Worksheets.Names Aspose.Cells API. For this particular example, the Excel file does only show one instance of the named range “access1” within the Microsoft Excel Names manager, as well as in the Microsoft Excel named range navigator drop down. This is an Office 2003 file.
Another related question - are there any significant enhancements between our Aspose.Cells version and the newest Aspose.Cells API as it is related to the parsing of named ranges in order to extract content from Workbooks?
Hi Amjad, thanks for the follow up. Our license does not allow this version, see below. Do you have any other earlier versions that you know of that would still resolve this issue? Thanks ---------
The subscription included in this license allows free
upgrades until 27 May 2009, but this version of the product was
released on 16 Oct 2009. Please renew the subscription or use a
previous version of the product.
unhandled exception occurred during the execution of the current web
request. Please review the stack trace for more information about the
error and where it originated in the code.
The subscription included in this license allows free upgrades until 27
May 2009, but this version of the product was released on 16 Oct 2009.
Please renew the subscription or use a previous version of the product.
Please first comment the licensing code and test the latest version provided by Amjad to check if it works fine for you. If it works fine than you have to upgrade your license subscription to use the latest version of Aspose.Cells as the issue may exist in the previous versions.
Hi Nausherwan, I’ve tried your newest Excel API but it is still causing the duplicates issue. How can I post the Excel file to you privately so that you can review?
As your file has some confidential data, you may check “Keep this post private” while replying to the post and attach your file. In this case only you and Aspose Staff will be able to see your post. Alternately, you can also send us your template file via email. Please follow the below mentioned steps to send us the file via email.
1: click the Contact button in the Post.
2: In the drop down list options click "Send nausherwan.aslam an Email”.
3: Attach the template file and send it.
4: Once you have done it, kindly confirm us on this thread.
This issue is caused by the named range belongs to different worksheet. So please change the codes to get the named range:
Name name = args.Item.DataItem as Name;
Range range = null;
if (name.SheetIndex == 0)
{
range = workbook.Worksheets.GetRangeByName(name.Text);
}
else
{
range = workbook.Worksheets.GetRangeByName(workbook.Worksheets[names[i].SheetIndex - 1].Name + "!" + name.Text);
}
We will provide a new method Name.GetRange to directly get the range by the name soon.
Hi Nausherwam, the API Name.GetRange() looks like it’s working great now. The duplicate Named Ranges (duplicate by their name and also by what they refer to) are no longer listed in the WorkBook.WorkSheets.Names collection. Thanks for your timely follow up. Shan