Table of Contents

Method Add

Namespace
DocWright.Spreadsheet
Assembly
DocWright.Spreadsheet.dll

Add(XlsxCellRange, string?, bool)

Makes a range a table, as Excel's Format as Table does: Excel's default style (TableStyleMedium2, row stripes), the columns named from the header cells, which then hold those names as text, merged cells inside unmerged. A range without a header row becomes a table whose header row is turned off, its columns named Column1 on: no cell moves (Excel's own command inserts a row above instead).

public XlsxTable Add(XlsxCellRange range, string? name = null, bool hasHeaders = true)

Parameters

range XlsxCellRange

The cells: with headers, the header row and at least one row of data.

name string

The table's name; null for Excel's next TableN.

hasHeaders bool

Whether the range's first row holds the headers.

Returns

XlsxTable

The table.

Exceptions

ArgumentException

The name is taken or is not a table's name, or the range has no data row.

InvalidOperationException

The range overlaps a table, or the sheet is not a worksheet.

InvalidDocumentException

A part of the workbook is malformed.