We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Non-sequenced Range

I have a range in my template that consist of un-sequenced cells. so say the Range range = A1-A3 and D1-D3 and F1-F3

When I do a GetRangeByName, it is returning a null. I assume this is becuase of the way the range is defined. is there a way to handle ranges like this?

See Attatched xls file for example of Range similar to this. Range name Teds

Hi,

Currently, you can only create and get those ranges which are of rectangular shape with their cells continuous and adjacent to each other. We may consider of supporting the non adjacent ranges of cells in future.

Thank you.

Hi,

Was this feature added to Aspose.Cells ?

Thanks.

Hi,

Yes, please try the method i.e.., Name.GetRanges() in the new version (attached). Check the following sample code:

Sample code:

Workbook workbook = new Workbook();
workbook.Open(@"F:\FileTemp\Book1.xls");
Name name = workbook.Worksheets.Names["Teds"];
Range[] ranges = name.GetRanges();
if (ranges != null)
{
for (int i = 0; i < ranges.Length; i++)
{
Console.WriteLine(ranges[i].FirstRow + ":" + ranges[i].FirstColumn);
}
}

Thank you.

Thanks for the reply,

I’m actually more interested in creating a non-continuous range, sorry for the confusion. Can you also provide a code sample for that ?

dstj.

Hi,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for considering Aspose.

Well, CreateRange() method allows the creation of Range in a sequence (Row * Column Matrix). Please see the following overloaded methods of CreateRange() which you can use to create range.

http://www.aspose.com/documentation/file-format-components/aspose.cells-for-.net-and-java/aspose.cells.cells.createrange_overloads.html

Thank You & Best Regards,

Ok, so creating a new non-sequenced range is not yet possible with Aspose.Cells.

Thanks for the follow-up.

Hi,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for considering Aspose.

Please add Non-sequenced Ranges with the following codes:

Workbook workbook = new Workbook();
int index = workbook.Worksheets.Names.Add("NonSequencedRange");
Name name = workbook.Worksheets.Names[index];
name.RefersTo = "=Sheet1!$A$1:$B$3,Sheet1!$E$5:$D$6";
workbook.Save (@"F:\FileTemp\dest.xls");

Currently, we can only process Non-sequenced Ranges as a defined Name.

Thank You & Best Regards,