Method Add
- Namespace
- DocWright.Spreadsheet
- Assembly
- DocWright.Spreadsheet.dll
Add(string, string)
Adds a name of the workbook.
public XlsxDefinedName Add(string name, string refersTo)
Parameters
namestringThe name. See Add(string, string, XlsxDocumentSheet?, string?, bool).
refersTostringWhat it stands for: a formula, with or without its
=, such asData!$B$2or0.07.
Returns
- XlsxDefinedName
The name.
Exceptions
- ArgumentNullException
nameorrefersTois null.- ArgumentException
Excel would refuse the name, it is taken, or
refersTois not a formula.- InvalidDocumentException
The workbook part is malformed.
Add(string, string, XlsxDocumentSheet?, string?, bool)
Adds a name, as Excel's New Name does, where Excel would list it.
public XlsxDefinedName Add(string name, string refersTo, XlsxDocumentSheet? scope, string? comment = null, bool hidden = false)
Parameters
namestringThe name. Excel's rules, measured: at most 255 characters, spaces at either end taken off; a letter, an underscore or one of the other characters Excel takes first; none of the characters Excel refuses (a space, most punctuation); not a cell reference (
A1,R1C1,R,C), notTRUEorFALSE. One of Excel's own names (Print_Area,Criteria, ...) is written as Excel writes it, with_xlnm..refersTostringWhat it stands for: a formula, with or without its
=. A reference to a sheet the workbook does not have is accepted, as Excel accepts it.scopeXlsxDocumentSheetThe sheet the name belongs to; null for the workbook.
Print_AreaandPrint_Titlesbelong to a sheet.commentstringThe name's comment, at most 255 characters; null for none.
hiddenboolWhether Excel's Name Manager hides it.
Returns
- XlsxDefinedName
The name.
Exceptions
- ArgumentNullException
nameorrefersTois null.- ArgumentException
Excel would refuse the name or the comment, the scope already has the name, the scope is a sheet of another workbook, or
refersTois not a formula.- InvalidDocumentException
The workbook part is malformed.