Method AddSheet
AddSheet(string)
Adds an empty worksheet at the end of the workbook.
public XlsxDocumentSheet AddSheet(string name)
Parameters
namestringThe sheet's name: 1 to 31 characters, none of
: \ / ? * [ ], no apostrophe at either end, and not the name of another sheet (names compare without regard to case). Normalize(string?, string) and MakeUnique(string, ICollection<string>) make one from arbitrary text.
Returns
- XlsxDocumentSheet
The new sheet. It is an ordinary sheet at once: its cells can be set before the workbook is saved.
Remarks
Excel refuses a workbook whose sheet names collide or are too long, so the name is checked here rather than discovered when the file will not open. The sheet is visible, and it does not become the sheet the workbook opens on.
Exceptions
- ArgumentNullException
nameis null.- ArgumentException
nameis not a legal sheet name, or another sheet has it.- InvalidDocumentException
The workbook part is malformed.