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

Free Support Forum - aspose.com

Named cells not supported (invalid cell name)

Hi,

I have named a cell as Test and now I cannot access it in code in Aspose.Cells

var nn = m_CurrentSheet.Cells["Test"];

It gives invalid cell name.

Also tried getting a range and this is coming null

CurrentWorkBook.Worksheets.GetRangeByName(name);

Although your methods allow us to create a range with 1 row and 1 column. Please suggest if this is bug or am I doing something wrong.

Nirdesh

Hi Nirdesh,

Thanks for your posting and using Aspose.Cells for .NET.

You get invalid cell name exception because you cannot access by its range (defined) name. You will have to use the cell name like A1, A2, B3 etc.

I have accessed the cell with its defined name workbook.Worksheets.GetRangeByName() method and it successfully returned the defined range. Please see the following code. I have attached the source file used in it for your reference. I used the latest version: Aspose.Cells for .NET 8.0.0 to test this issue.

C#


string filePath = @“F:\Shak-Data-RW\Downloads\source.xlsx”;


Workbook workbook = new Workbook(filePath);


Worksheet worksheet = workbook.Worksheets[0];


Range range = workbook.Worksheets.GetRangeByName(“TestCell”);


Console.WriteLine(range.Value);
Console Output:
Sample