Table of Contents

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

name string

The name. See Add(string, string, XlsxDocumentSheet?, string?, bool).

refersTo string

What it stands for: a formula, with or without its =, such as Data!$B$2 or 0.07.

Returns

XlsxDefinedName

The name.

Exceptions

ArgumentNullException

name or refersTo is null.

ArgumentException

Excel would refuse the name, it is taken, or refersTo is 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

name string

The 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), not TRUE or FALSE. One of Excel's own names (Print_Area, Criteria, ...) is written as Excel writes it, with _xlnm..

refersTo string

What 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.

scope XlsxDocumentSheet

The sheet the name belongs to; null for the workbook. Print_Area and Print_Titles belong to a sheet.

comment string

The name's comment, at most 255 characters; null for none.

hidden bool

Whether Excel's Name Manager hides it.

Returns

XlsxDefinedName

The name.

Exceptions

ArgumentNullException

name or refersTo is 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 refersTo is not a formula.

InvalidDocumentException

The workbook part is malformed.