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
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.
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
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];
Is there an equivalent of Worksheets.GetRangeByName in java?
Ah I see, you have to do it on the WorksheetCollection and not on the worksheet itself.
Thanks.
Yes, your understanding is correct. For your information, Worksheets class has been renamed to become WorksheetCollection now.