Class XlsxDocumentSheet
- Namespace
- DocWright.Spreadsheet
- Assembly
- DocWright.Spreadsheet.dll
One sheet of an opened workbook.
public sealed class XlsxDocumentSheet
- Inheritance
-
XlsxDocumentSheet
- Inherited Members
Properties
- AllowEditRanges
Gets the sheet's allow-edit ranges.
- AutoFilter
Gets the range the sheet's autofilter covers, its header row first; null when the sheet has none.
- BaseColumnWidth
Gets the number of characters of the default font a column is wide when nothing states its width: 8 unless the sheet says otherwise.
- Cells
Gets the sheet's cells one at a time, in the order the sheet stores them - by row and then by column in any file Excel wrote.
- Charts
Gets the sheet's charts: a worksheet's, in its drawing; a chart sheet's one. Each as its part states it: type, title, series with the ranges they read, axes, legend, and where it is.
- Comments
Gets the sheet's notes (Excel's legacy comments): in the order the file lists them, to add, change and remove as Excel's New Note, Edit Note and Delete Note do.
- ConditionalFormats
Gets the sheet's conditional formats: the rules Excel's Conditional Formatting sets, each with the cells it covers, to list, add, change, reorder and remove. EffectiveStyle(int, int, XlsxConditionalOptions?) says what a cell looks like with them.
- Controls
Gets the sheet's form controls (Excel's Form Controls: check boxes, option buttons, lists, buttons, scroll bars, spinners).
- DefaultColumnWidth
Gets the width the sheet gives a column that states none, in the file's unit (see GetColumnWidth(int)); null when the sheet does not say, and the width is BaseColumnWidth characters of the workbook's default font plus the cell's padding.
- DefaultRowHeight
Gets the height the sheet gives a row that states none, in points; null when the sheet does not say, and the height follows from the workbook's default font.
- Dimension
Gets the smallest range that holds every cell the sheet stores, or null when it stores none.
- Document
Gets the workbook the sheet belongs to.
- EmbeddedObjects
Gets the sheet's OLE objects: embedded files and documents, and links to them.
- Filters
Gets the criteria of the sheet's autofilter, one for each column that has one, from the left.
- FrozenColumns
Gets the number of columns frozen at the left of the sheet; 0 when none are.
- FrozenRows
Gets the number of rows frozen at the top of the sheet; 0 when none are.
- Hyperlinks
Gets the sheet's hyperlinks, in the order the file lists them: links to add and remove, as Excel's Insert Link and Remove Hyperlink do.
- IsProtected
Gets whether the sheet is protected (its
sheetProtectionstatessheet="1").
- MergedRanges
Gets the merged ranges of the sheet, in the order the sheet lists them, with any merged or unmerged since the workbook was opened applied.
- Name
Gets or sets the sheet's name, as its tab shows it.
- OutlineSummaryBelow
Gets or sets whether a group's summary row is the row below it (true, Excel's default) or the row above it. The button that collapses the group sits on the summary row.
- OutlineSummaryRight
Gets or sets whether a group's summary column is the column to its right (true, Excel's default) or to its left.
- PageSetup
Gets how the sheet says it is printed: paper, orientation, margins, scaling, print area and titles, manual page breaks, header and footer. Excel's defaults where the sheet says nothing, and for a sheet that is not a worksheet.
- Pictures
Gets the sheet's pictures: listed with where they are, their size, alternative text and bytes; added at a cell, moved, resized and removed. Charts and shapes in the same drawing are kept as they are.
- PivotTables
Gets the sheet's pivot tables, as their definitions and caches state them. A chart sheet has none.
- Protection
Gets what the protected sheet allows, or null when the sheet is not protected.
- Scenarios
Gets the sheet's scenarios (Excel's Scenario Manager); none on a sheet that is not a worksheet.
- Shapes
Gets the sheet's shapes, text boxes, connectors and groups. A chart sheet has none.
- ShowGridLines
Gets whether the grid between the cells is shown on screen. True unless the sheet turns it off.
- Sparklines
Gets the sheet's sparkline groups. A chart sheet has none.
- TabColor
Gets or sets the colour of the sheet's tab; null for none.
- Tables
Gets the sheet's tables (Excel's Format as Table): listed, added over a range, resized, restyled, given totals and removed. Setting a table's header cell renames its column, and every structured reference to the column follows.
- ThreadedComments
Gets the sheet's threaded comments, as Microsoft 365 writes them: each with its author, its time and its replies. They are read and removed; adding one is not supported.
- Validations
Gets the sheet's data validation: the rules Excel's Data Validation sets, each with the cells it covers, to list, add, change and remove, and to ask whether a value would be accepted.
- Visibility
Gets or sets whether the sheet is shown.
Methods
- ApplyFilter(int, XlsxFilterCriterion)
Gives a column of the autofilter a criterion and hides the rows that do not pass, as Excel does when a filter is applied.
- Clear(int, int)
Empties a cell: its value and its formula go, and the cell stays for its format.
- Clear(string)
Empties a cell by its reference. See Clear(int, int).
- ClearFilters()
Takes every criterion off the autofilter and shows every row of its range, as Excel's Clear does. The autofilter stays.
- CopyTo(int, string?)
Copies the sheet within its workbook.
- Delete()
Deletes the sheet from the workbook.
- DeleteColumns(int, int)
Deletes columns; the columns to the right move left.
- DeleteRows(int, int)
Deletes rows; the rows below move up.
- EffectiveStyle(int, int, XlsxConditionalOptions?)
Returns what a cell looks like with the sheet's conditional formats applied, as Excel draws it: its own style with the formats of the rules that hold for it laid over (the rule of the higher priority first, a stop-if-true rule ending the list), and the colour scale's fill, the data bar and the icon it gets.
- EffectiveStyle(string, XlsxConditionalOptions?)
Returns what a cell looks like with the sheet's conditional formats applied. See EffectiveStyle(int, int, XlsxConditionalOptions?).
- Evaluate(string, XlsxCalculationOptions?)
Calculates a formula against the sheet, as if it were in a cell of it, and writes it nowhere: its references read the cells' values as the workbook holds them.
- ExportArray(XlsxCellRange?, XlsxExportOptions?)
Reads a range into a two-dimensional array, every row of the range included: text as string, a number as decimal (double past its range), a boolean as bool, a cell that shows a date as DateTime, an empty cell as null.
- ExportDataTable(XlsxCellRange?, XlsxExportOptions?)
Reads a range into a new table: one column for each column of the range, typed by what the column holds, and one row for each row.
- ExportObjects<T>(XlsxCellRange?, XlsxExportOptions?)
Reads a range into objects: one for each row under the headings, each heading's column going to the public settable property of that name.
- FillDataTable(DataTable, XlsxCellRange?, XlsxExportOptions?)
Reads a range into a table of your own: each cell is given as the type of the column it goes to, so the table's schema is the one you defined.
- FillTemplate(IReadOnlyDictionary<string, object?>, XlsxTemplateOptions?)
Fills the sheet as a template: each block of rows marked
{{#Name}}is repeated once for each item of the listName, with the item's members filled in, and every other placeholder is filled fromdata.
- FindPlaceholderNames(XlsxPlaceholderOptions?)
Lists the placeholders the sheet's text cells hold, such as
{{Customer}}.
- FindRegex(string, XlsxFindOptions?)
Finds every match of a regular expression in the sheet's cells.
- FindText(string, XlsxFindOptions?)
Finds every occurrence of a text in the sheet's cells.
- FindWildcards(string, XlsxFindOptions?)
Finds every match of an Excel wildcard pattern in the sheet's cells:
?any one character,*any run,~before either for the character itself.
- FreezePanes(int, int)
Freezes rows at the top and columns at the left of the sheet, as Excel's Freeze Panes does (FrozenRows, FrozenColumns).
- GetCell(int, int)
Gets one cell.
- GetCell(string)
Gets one cell by its reference.
- GetColumnOutlineLevel(int)
Gets the outline level of a column: 0 when it is in no group, up to 7.
- GetColumnWidth(int)
Gets the width the sheet states for a column.
- GetRowHeight(int)
Gets the height the sheet states for a row.
- GetRowOutlineLevel(int)
Gets the outline level of a row: 0 when it is in no group, up to 7.
- GroupColumns(int, int, bool)
Groups columns, as Excel's Data > Group does. See GroupRows(int, int, bool).
- GroupRows(int, int, bool)
Groups rows, as Excel's Data > Group does: each row goes one outline level deeper.
- ImportData(DataTable, int, int, XlsxImportOptions?)
Writes a table into the sheet: one row for each of its rows, one column for each of its columns.
- ImportData(DataView, int, int, XlsxImportOptions?)
Writes a view of a table into the sheet: the rows the view shows, in the view's order. See ImportData(DataTable, int, int, XlsxImportOptions?) for how values are written.
- ImportData(object?[,], int, int, XlsxImportOptions?)
Writes a two-dimensional array into the sheet: its first dimension down the rows, its second across the columns. An array has no names, so no header row is written and Columns must be empty. See ImportData(DataTable, int, int, XlsxImportOptions?) for how values are written.
- ImportData<T>(IEnumerable<T>, int, int, XlsxImportOptions?)
Writes a sequence of items into the sheet: one row for each item, one column for each public readable property whose type a cell can hold (or the ones Columns names). A sequence of plain values, such as numbers or strings, is one column headed
Value. See ImportData(DataTable, int, int, XlsxImportOptions?) for how values are written.
- InsertColumns(int, int, XlsxInsertOptions?)
Inserts columns; the columns from
aton move right.
- InsertRows(int, int, XlsxInsertOptions?)
Inserts rows; the rows from
aton move down.
- IsColumnHidden(int)
Gets whether a column is hidden: marked hidden, or given a width of zero.
- IsRowHidden(int)
Gets whether a row is hidden: marked hidden, or given a height of zero.
- Merge(XlsxCellRange)
Merges a range of cells into one.
- MoveTo(int)
Moves the sheet to another place among the workbook's tabs.
- Protect(XlsxSheetProtection?, string?)
Protects the sheet as Excel's Protect Sheet does: what it allows, and a password hashed as Excel hashes it (SHA-512, a random 16-byte salt, 100,000 spins) or none. A protection the sheet already has is replaced.
- Remove(int, int)
Takes a cell out of the sheet altogether: value, formula and format. Nothing moves; the cells around it stay where they are.
- Remove(string)
Takes a cell out of the sheet by its reference. See Remove(int, int).
- ReplacePlaceholders(IReadOnlyDictionary<string, object?>, XlsxPlaceholderOptions?)
Fills the placeholders in the sheet's text cells from a dictionary.
- ReplaceRegex(string, string, XlsxFindOptions?)
Replaces every match of a regular expression in the sheet's cells.
- ReplaceText(string, string, XlsxFindOptions?)
Replaces every occurrence of a text in the sheet's cells.
- SetArrayFormula(string, string)
Enters an array formula over a range, as Excel's Ctrl+Shift+Enter does (Phase 210): every cell of the range computes it, a single value filling them all, a row or a column repeated across,
#N/Awhere the result is smaller. An array formula already in the range is replaced when it lies wholly inside it.
- SetAutoFilter(XlsxCellRange?)
Gives the sheet an autofilter over a range, or takes it away: the arrows Excel's Data > Filter puts on the range's first row.
- SetColumnHidden(int, bool)
Hides or shows a column, as Excel's Hide and Unhide do. Its width is kept.
- SetColumnWidth(int, decimal)
Sets a column's width.
- SetDynamicFormula(string, string)
Enters a dynamic array formula in a cell, as Excel 365 enters any formula (Phase 210): its result spills from the cell as far as it reaches when the workbook is calculated, or the cell shows
#SPILL!when a cell it would fill holds something. What the cell spilled before goes with the formula it held.
- SetFormula(int, int, string)
Sets a cell's formula. Its format is kept; it has no value until an application calculates it.
- SetFormula(string, string)
Sets a cell's formula by its reference. See SetFormula(int, int, string).
- SetRichText(int, int, XlsxRichText)
Sets a cell's text formatted in parts (Phase 205): its runs, each with its format. The cell's format is kept, and a run without a format takes the cell's own font. Value then reads as the text, the runs joined; RichText as the runs.
- SetRichText(string, XlsxRichText)
Sets a cell's text formatted in parts by its reference. See SetRichText(int, int, XlsxRichText).
- SetRowHeight(int, decimal)
Sets a row's height.
- SetRowHidden(int, bool)
Hides or shows a row, as Excel's Hide and Unhide do. Its height is kept.
- SetStyle(int, int, XlsxCellStyle)
Sets how a cell looks. Its value and its formula are kept.
- SetStyle(string, XlsxCellStyle)
Sets how a cell looks by its reference. See SetStyle(int, int, XlsxCellStyle).
- SetValue(int, int, XlsxCellValue)
Sets a cell's value. A formula the cell had is removed; its format is kept.
- SetValue(string, XlsxCellValue)
Sets a cell's value by its reference. See SetValue(int, int, XlsxCellValue).
- Sort(XlsxCellRange, params XlsxSortKey[])
Sorts the rows of a range by one or more of its columns, as Excel's Data > Sort does. The range has no header row; see Sort(XlsxCellRange, XlsxSortOptions?, params XlsxSortKey[]).
- Sort(XlsxCellRange, XlsxSortOptions?, params XlsxSortKey[])
Sorts the rows of a range by one or more of its columns, as Excel's Data > Sort does.
- ToCsv(Stream, XlsxCsvOptions?)
Writes the sheet as delimited text (CSV) in UTF-8.
- ToCsv(TextWriter, XlsxCsvOptions?)
Writes the sheet as delimited text (CSV).
- ToJson(Stream, XlsxJsonOptions?)
Writes the sheet as JSON, in UTF-8 without a byte order mark.
- ToMarkdown(TextWriter, XlsxMarkdownOptions?)
Writes the sheet as a Markdown table (the pipe table of GitHub Flavored Markdown).
- UngroupColumns(int, int)
Ungroups columns, as Excel's Data > Ungroup does. See UngroupRows(int, int).
- UngroupRows(int, int)
Ungroups rows, as Excel's Data > Ungroup does: each grouped row goes one outline level up.
- Unmerge(XlsxCellRange)
Unmerges a merged range.
- Unprotect(string?)
Removes the sheet's protection, as Excel's Unprotect Sheet does: with the password when it has one. A sheet that is not protected is left as it is.