How do I use Named Ranges with XlsIO?
Named ranges collection belongs to the workbook and not to the worksheet. If you define two named ranges with the same name, then the named range that was defined last will replace the previous named range.
C#
// Defining a Range
IName lname = sheet.Names.Add("Products");
lname.RefersToRange = sheet.Range["A1:A6"];
// Defining the Range and using it in the Formula
IName lname1 = sheet.Names.Add("One");
lname1.RefersToRange = sheet.Range["C3"];
IName lname2 = sheet.Names.Add("Two");
lname2.RefersToRange = sheet.Range["D3"];
// Formula using Defined Names
sheet.Range["E3"].Formula = "=SUM(One,Two)";
VB
Dim lname As IName = sheet.Names.Add("Products")
lname.RefersToRange = sheet.Range("A1:A6")
Dim lname1 As IName = sheet.Names.Add("One")
lname1.RefersToRange = sheet.Range("C3")
Dim lname2 As IName = sheet.Names.Add("Two")
lname2.RefersToRange = sheet.Range("D3")
sheet.Range("E3").Formula = "=SUM(One,Two)"
Here is the sample for your reference:
https://www.syncfusion.com/downloads/support/directtrac/89898/NamedRanges421999033.zip
Take a moment to peruse the documentation where you can find basic Excel document processing options along with the features like import and export data, chart, formulas, conditional formatting, data validation, tables, pivot tables and protect the Excel documents, and most importantly, the PDF, CSV and Image conversions with code examples.
Conclusion
I hope you enjoyed learning about how do I use named ranges with XlsIO.
You can refer to our WF XlsIO feature tour page to know about its other groundbreaking feature representations. You can also explore our documentation to understand how to create and manipulate data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!