Free Support Forum - aspose.com

Questions about ranges

Hi everyone,

I have two questions about Ranges for Aspose Cells.

#1 Question /////////////////////////////////////////////////////////////////////////////////////

I created by hand an excel sheet with some ranges. When i want to get all the ranges I just use the GetNamedRanges method. Everything works fine.

But then I added some “Excel tables” in my sheet (let’s call one of them “Table1”). Those objects can be retrieved with the ListObjects method.

Here comes the problem: I also added ranges into my “Excel tables” e.g. I want to add into the excel table called “Table1” a range for one specific cell (let’s call it rangeSpecificCell). I can do it with excel but when I want to analyze my excel file through Aspose I have the following issue :

None of the method GetNamedRanges or ListObjects recognize the range that should be contained by the Excel Tables “Table1” (aka rangeSpecificCell). Do you have any tips to manage this situation ?



#2 Question /////////////////////////////////////////////////////////////////////////////////////

Is it possible to use the commentary field for a range ? (Excel 2007)
I found some posts on this forum but with no examples of use…


Thanks in advance for your answers (and sorry for my poor english !)

Best Regards,
Louis.

Hi,

1) Please create a sample console application, zip it and post it here to show the issue, we will check it soon.

2) Please elaborate more and explain your requirement. You may attach sample files, screen shot. This way we can understand your needs well.

Thank you.

Dear Amjad Sahi,

1. Please find enclosed an Excel sheet “Demo.xlsx” and the image “question1.png” that may help you to understand the problem.

After understanding the situation with “question1.png”, the following code shows the problem

// i open my report
Workbook report = new Workbook(“C:\Users\lowia\Desktop\Demo.xlsx”);

// i want to list all the ranges
Range[] ranges = report.Worksheets.GetNamedRanges();
foreach (Range unRange in ranges)
{
Console.WriteLine(unRange.Name);
}
// regarding Demo.xlsx, i should have “Name” and “Name2”
// but as “Name” is in an Excel table i only got “Name2” with GetNamedRanges()


// i want to list the Table
ListObjectCollection tables = report.Worksheets[0].ListObjects;
foreach (ListObject aTable in tables)
{
Console.WriteLine(aTable.DisplayName);
// it finds the right table but when you observe the content of the tables
// it says that none of the cells in the table has a range (but we know that there’s a range called “Name” in it)
Range rangeOfMyTable = aTable.DataRange;
}

Console.ReadKey();


2. In the zip file you will find a pic called “question2” that precise my request.

Thanks in advance,

Best Regards,
Louis.



Hi Louis,


Thank you for providing us the investigation material.

We have logged two tickets for your said issues. Ticket IDs are also available for your reference.

CELLSNET-27759: is logged as “New Feature” request, as we currently do not support Table source as Named Range.

CELLSNET-27760: is logged as “Investigation”, because we assume that all ranges in an Excel file should be listed in workbook.worksheets.GetNamedRanges(). So your provided source code should also display “Name” that is a valid range in your provided “Demo.xlsx” file.

We will keep you posted on these issues.

Hi babar raza,

Thanks for the quick reply. I’m waiting for some informations.

Best Regards,
Louis.

Hi,

We have fixed this issue. Please download Aspose.Cells for .NET v5.3.3.2

Hi Louis,


In reference to Question-2 from your post 305832, I assume you need to add comments for the Names in MS Excel Name Manager. Please try below source code. Also attached is the output for your reference.

Sample C# code.

Workbook report = new Workbook(“C:\temp\Demo.xlsx”);

NameCollection names = report.Worksheets.Names;

for (int i = 0; i < names.Count; i++)

{

Name name = names[i];

Console.WriteLine(name.Text);

name.Comment = "Adding comment for Range " + i;

}

report.Save(“C:\temp\name.xlsx”);

Hi,

Please try Worksheets.GetNamedRangesAndTables method.

babar.raza & mshakell faiz

Thanks for the reply guys !
I tested your sample of code and the new method GetNamedRangesAndTables, everything works fine !

Thanks for the appreciated help,

Best Regards,
Louis.

The issues you have found earlier (filed as 27760) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.

The issues you have found earlier (filed as ) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by MuzammilKhan