Aspose Range Issue

Hi Team,

I am attaching test file. In this file I have range with name “t1_lock”.
When i am trying to get data from this name then Aspose return NULL.
It did not find this range.
Range[] ranges = workbook.Worksheets.GetNamedRanges(); //test
string rTemp = string.Empty;
foreach (var rr in ranges)
{
rTemp = rr.Name;
}

//or by name

Range rangelocked = workbook.Worksheets.GetRangeByName(“t1_lock”);

Please help,
paRangeTest.zip (5.6 KB)

@rudolfkalik

Thanks for using Aspose APIs.

Please use the Workbook.Worksheets.Names property for your needs. Please see the following screenshot that shows your mentioned named range for your reference.

Screenshot:

Hi Faiz,

I got this name.
NameCollection names = workbook.Worksheets.Names; //test
string nTemp = string.Empty;
foreach (var nn in names)
{
nTemp = nn.Text;
}

But I need to get data from this Range.
And I know how to get data by Range name.
How can I get data if I know only Name?

Please help.
pa

@rudolfkalik

Please see the following code. It works fine and fit your needs. It returns the array of ranges from the named range.

C#

Workbook wb = new Workbook("RangeTest.xlsx");

Name nm = wb.Worksheets.Names[0];

Range[] rngs = nm.GetRanges();

Thank you for your help.

Hi Faiz
How to protect worksheet with only ‘Select unlocked cells’ checked?

Worksheet wsPr = workbook.Worksheets[sheet.Name];
wsPr.Protect(ProtectionType.All, “”, “”);

Please help.
pa

@rudolfkalik,

See the reply in your other thread:

When I try to save file
workbook.Save(filePath);
I want to save with this settings (see attached image)Protect Sheet.png (3.9 KB)

Please help

Thank you,
pa

@rudolfkalik,

Thanks for the screenshot.

See the document for your reference, you need to use the following line of code:
e.g
Sample code:

// Allowing users to select unlocked cells of the worksheet
worksheet.Protection.AllowSelectingUnlockedCell = true;

Hope, this helps a bit.

Thank you for your help.
pa

@rudolfkalik,

Good to know that your issue is sorted out now. Feel free to contact us any time if you need further help or have some other issue or queries, we will be happy to assist you soon.