The Syncfusion native Blazor components library offers 70+ UI and Data Viz web controls that are responsive and lightweight for building modern web apps.
.NET PDF framework is a high-performance and comprehensive library used to create, read, merge, split, secure, edit, view, and review PDF files in C#/VB.NET.
I’d like to have two informations ! Actually, I have created in my excel file (in Excel not by using syncfusion) a defined name cell call “test”. The only way to get the text in this one is with the method “Range["test"].Text” and not thanks to the method : sheet.Names("CellName").Value. Is it normal ? And secondly, I’d like to know if it’s possible to check if an defined named cell exist without crashing. Indeed, if the cell doesn’t exist in the Excel file, I’d like to know that by making a test. For the moment, I have always an exception and I don’t want to use a “try/catch”.
LRLokesh R Syncfusion Team July 28, 2010 05:56 AM UTC
Hi Benoit,
Thank you very much for your interest on Syncfusion products.
I have analyzed the two queries posted in your last update and given below the details in separate headings.
sheet.Names("CellName").Value:
The Value property associated with the INames will return only the A-1 style notation of the referred range which we represent in the macros without a "=" sign. If you have to retrieve a value of the named range you need to use the below code snippet instead of the above.
[C#] sheet.Names["Test"].ReferToRange.Value;
Named cell exist without crashing:
you can read all the named cells by iterating the INames collections. I have given below the code snippet for the same.
[C#] foreach (IName namedCell in wkBook.Names) { if (namedCell.Name == "Test") { System.Console.WriteLine(namedCell.RefersToRange.Value); } }
[VB]
For Each namedCell As IName In wkBook.Names If namedCell.Name = "Test" Then System.Console.WriteLine(namedCell.RefersToRange.Value) End If Next namedCell
Please, let us know if you need any clarifications.