Find cell by name


#1

Hi!

I need to find a cell by it’s name.
The reason: I load a .xls File and will copy the styles of some cells to those i’m creating.
Now i tried: cells[“A1”] -> work fine

Now the problem:

When i will get the cell by it’s really name ( cells[“someName”] ) i get an exception “Invalid cell name” though i set the name of this cell direct in Excel and saved this file for loading…

When i debug my app, cells[“IR2”] work fine but in reality i named this cell “TestCell” and by typing cells[“TestCell”] the exception is thrown.

Is this a bug or i’m using the wrong method?

Thanks, Stefan


#2

Dear Stefan,

Thanks for your consideration.

When you use Cell[string cellName] indexer to get a cell, only standard cell name is supported, for example, “A1”, “IR2”, etc. Custom cell name is not supported now.


#3

Laurence,

I note that your reply to stefan was dated in February of this year - have you fixed your program to enable the use of custom cell names yet? If so, how would I go about it.

If not, do you intend to provide this capability - custom names are widely used and the lack of support for this facility is the only thing that could cause me to look for alternatives to your product - I would otherwise purchase it.

Thanks

Arthur


#4

Dear Arthur,

Yes. Now you can do it. Please refer to Worksheets.GetRangeByName method.

For example, you define a custom name “CustomName1” for a cell, you can use the following code to get this cell.

Range range = excel.Worksheets.GetRangeByName(“CustomName1”);
Cell cell = range[0,0];


#5

Is there an equivalent of Worksheets.GetRangeByName in java?


#6

@TMamer,

Yes, similar method is there in Aspose.Cells for Java, see the API Reference page:
https://apireference.aspose.com/java/cells/com.aspose.cells/worksheetcollection#getRangeByName(java.lang.String)


#7

Ah I see, you have to do it on the WorksheetCollection and not on the worksheet itself.

Thanks.


#8

@TMamer,

Yes, your understanding is correct. For your information, Worksheets class has been renamed to become WorksheetCollection now.