NanoXLSX.Core 3.0.0-rc.3
Loading...
Searching...
No Matches
NanoXLSX.Worksheet Class Reference

Class representing a worksheet of a workbook. More...

Public Types

enum  CellDirection { ColumnToColumn , RowToRow , Disabled }
 Enum to define the direction when using AddNextCell method. More...
enum  SheetProtectionValue {
  Objects , Scenarios , FormatCells , FormatColumns ,
  FormatRows , InsertColumns , InsertRows , InsertHyperlinks ,
  DeleteColumns , DeleteRows , SelectLockedCells , Sort ,
  AutoFilter , PivotTables , SelectUnlockedCells
}
 Enum to define the possible protection types when protecting a worksheet. More...
enum  WorksheetPane { BottomRight , TopRight , BottomLeft , TopLeft }
 Enum to define the pane position or active pane in a slip worksheet. More...
enum  SheetViewType { Normal , PageBreakPreview , PageLayout }
 Enum to define how a worksheet is displayed in the spreadsheet application (Excel). More...

Public Member Functions

 Worksheet ()
 Default Constructor.
 Worksheet (string name)
 Constructor with worksheet name.
 Worksheet (string name, int id, Workbook reference)
 Constructor with name and sheet ID.
void AddNextCell (object value)
 Adds an object to the next cell position. If the type of the value does not match with one of the supported data types, it will be cast to a String. A prepared object of the type Cell will not be cast but adjusted.
void AddNextCell (object value, Style style)
 Adds an object to the next cell position. If the type of the value does not match with one of the supported data types, it will be cast to a String. A prepared object of the type Cell will not be cast but adjusted.
void AddCell (object value, int columnNumber, int rowNumber)
 Adds an object to the defined cell address. If the type of the value does not match with one of the supported data types, it will be cast to a String. A prepared object of the type Cell will not be cast but adjusted.
void AddCell (object value, int columnNumber, int rowNumber, Style style)
 Adds an object to the defined cell address. If the type of the value does not match with one of the supported data types, it will be cast to a String. A prepared object of the type Cell will not be cast but adjusted.
void AddCell (object value, string address)
 Adds an object to the defined cell address. If the type of the value does not match with one of the supported data types, it will be cast to a String. A prepared object of the type Cell will not be cast but adjusted.
void AddCell (object value, string address, Style style)
 Adds an object to the defined cell address. If the type of the value does not match with one of the supported data types, it will be cast to a String. A prepared object of the type Cell will not be cast but adjusted.
void AddCellFormula (string formula, string address)
 Adds a cell formula as string to the defined cell address.
void AddCellFormula (string formula, string address, Style style)
 Adds a cell formula as string to the defined cell address.
void AddCellFormula (string formula, int columnNumber, int rowNumber)
 Adds a cell formula as string to the defined cell address.
void AddCellFormula (string formula, int columnNumber, int rowNumber, Style style)
 Adds a cell formula as string to the defined cell address.
void AddNextCellFormula (string formula)
 Adds a formula as string to the next cell position.
void AddNextCellFormula (string formula, Style style)
 Adds a formula as string to the next cell position.
void AddCellRange (IReadOnlyList< object > values, Address startAddress, Address endAddress)
 Adds a list of object values to a defined cell range. If the type of the particular value does not match with one of the supported data types, it will be cast to a String. Prepared objects of the type Cell will not be cast but adjusted.
void AddCellRange (IReadOnlyList< object > values, Address startAddress, Address endAddress, Style style)
 Adds a list of object values to a defined cell range. If the type of the particular value does not match with one of the supported data types, it will be cast to a String. Prepared objects of the type Cell will not be cast but adjusted.
void AddCellRange (IReadOnlyList< object > values, string cellRange)
 Adds a list of object values to a defined cell range. If the type of the particular value does not match with one of the supported data types, it will be cast to a String. Prepared objects of the type Cell will not be cast but adjusted.
void AddCellRange (IReadOnlyList< object > values, string cellRange, Style style)
 Adds a list of object values to a defined cell range. If the type of the particular value does not match with one of the supported data types, it will be cast to a String. Prepared objects of the type Cell will not be cast but adjusted.
bool RemoveCell (int columnNumber, int rowNumber)
 Removes a previous inserted cell at the defined address.
bool RemoveCell (string address)
 Removes a previous inserted cell at the defined address.
void SetStyle (Range cellRange, Style style)
 Sets the passed style on the passed cell range. If cells are already existing, the style will be added or replaced. Otherwise, an empty cell will be added with the assigned style. If the passed style is null, all styles will be removed on existing cells and no additional (empty) cells are added to the worksheet.
void SetStyle (Address startAddress, Address endAddress, Style style)
 Sets the passed style on the passed cell range, derived from a start and end address. If cells are already existing, the style will be added or replaced. Otherwise, an empty cell will be added with the assigned style. If the passed style is null, all styles will be removed on existing cells and no additional (empty) cells are added to the worksheet.
void SetStyle (Address address, Style style)
 Sets the passed style on the passed (singular) cell address. If the cell is already existing, the style will be added or replaced. Otherwise, an empty cell will be added with the assigned style. If the passed style is null, all styles will be removed on existing cells and no additional (empty) cells are added to the worksheet.
void SetStyle (string addressExpression, Style style)
 Sets the passed style on the passed address expression. Such an expression may be a single cell or a cell range. If the cell is already existing, the style will be added or replaced. Otherwise, an empty cell will be added with the assigned style. If the passed style is null, all styles will be removed on existing cells and no additional (empty) cells are added to the worksheet.
int GetFirstColumnNumber ()
 Gets the first existing column number in the current worksheet (zero-based).
int GetFirstDataColumnNumber ()
 Gets the first existing column number with data in the current worksheet (zero-based).
int GetFirstRowNumber ()
 Gets the first existing row number in the current worksheet (zero-based).
int GetFirstDataRowNumber ()
 Gets the first existing row number with data in the current worksheet (zero-based).
int GetLastColumnNumber ()
 Gets the last existing column number in the current worksheet (zero-based).
int GetLastDataColumnNumber ()
 Gets the last existing column number with data in the current worksheet (zero-based).
int GetLastRowNumber ()
 Gets the last existing row number in the current worksheet (zero-based).
int GetLastDataRowNumber ()
 Gets the last existing row number with data in the current worksheet (zero-based).
AddressGetLastCellAddress ()
 Gets the last existing cell in the current worksheet (bottom right).
AddressGetLastDataCellAddress ()
 Gets the last existing cell with data in the current worksheet (bottom right).
AddressGetFirstCellAddress ()
 Gets the first existing cell in the current worksheet (bottom right).
AddressGetFirstDataCellAddress ()
 Gets the first existing cell with data in the current worksheet (bottom right).
void InsertRow (int rowNumber, int numberOfNewRows)
 Inserts 'count' rows below the specified 'rowNumber'. Existing cells are moved down by the number of new rows. The inserted, new rows inherits the style of the original cell at the defined row number. The inserted cells are empty. The values can be set later.
void InsertColumn (int columnNumber, int numberOfNewColumns)
 Inserts 'count' columns right of the specified 'columnNumber'. Existing cells are moved to the right by the number of new columns. The inserted, new columns inherits the style of the original cell at the defined column number. The inserted cells are empty. The values can be set later.
Cell FirstCellByValue (object searchValue)
 Searches for the first occurrence of the value.
Cell FirstOrDefaultCell (Func< Cell, bool > predicate)
 Searches for the first occurrence of the expression. Example: var cell = worksheet.FindCell(c => c.Value?.ToString().Contains("searchValue"));.
List< CellCellsByValue (object searchValue)
 Searches for cells that contain the specified value and returns a list of these cells.
int ReplaceCellValue (object oldValue, object newValue)
 Replaces all occurrences of 'oldValue' with 'newValue' and returns the number of replacements.
void AddAllowedActionOnSheetProtection (SheetProtectionValue typeOfProtection)
 Method to add allowed actions if the worksheet is protected. If one or more values are added, UseSheetProtection will be set to true.
void AddHiddenColumn (int columnNumber)
 Sets the defined column as hidden.
void AddHiddenColumn (string columnAddress)
 Sets the defined column as hidden.
void AddHiddenRow (int rowNumber)
 Sets the defined row as hidden.
void ClearActiveStyle ()
 Clears the active style of the worksheet. All later added calls will contain no style unless another active style is set.
Cell GetCell (Address address)
 Gets the cell of the specified address.
Cell GetCell (int columnNumber, int rowNumber)
 Gets the cell of the specified column and row number (zero-based).
bool HasCell (Address address)
 Gets whether the specified address exists in the worksheet. Existing means that a value was stored at the address.
bool HasCell (int columnNumber, int rowNumber)
 Gets whether the specified address exists in the worksheet. Existing means that a value was stored at the address.
void ResetColumn (int columnNumber)
 Resets the defined column, if existing. The corresponding instance will be removed from Columns.
IReadOnlyList< CellGetRow (int rowNumber)
 Gets a row as list of cell objects.
IReadOnlyList< CellGetColumn (string columnAddress)
 Gets a column as list of cell objects.
IReadOnlyList< CellGetColumn (int columnNumber)
 Gets a column as list of cell objects.
int GetCurrentColumnNumber ()
 Gets the current column number (zero based).
int GetCurrentRowNumber ()
 Gets the current row number (zero based).
void GoToNextColumn ()
 Moves the current position to the next column.
void GoToNextColumn (int numberOfColumns, bool keepRowPosition=false)
 Moves the current position to the next column with the number of cells to move.
void GoToNextRow ()
 Moves the current position to the next row (use for a new line).
void GoToNextRow (int numberOfRows, bool keepColumnPosition=false)
 Moves the current position to the next row with the number of cells to move (use for a new line).
string MergeCells (Range cellRange)
 Merges the defined cell range.
string MergeCells (string cellRange)
 Merges the defined cell range.
string MergeCells (Address startAddress, Address endAddress)
 Merges the defined cell range.
void RemoveAutoFilter ()
 Removes auto filters from the worksheet.
void RemoveHiddenColumn (int columnNumber)
 Sets a previously defined, hidden column as visible again.
void RemoveHiddenColumn (string columnAddress)
 Sets a previously defined, hidden column as visible again.
void RemoveHiddenRow (int rowNumber)
 Sets a previously defined, hidden row as visible again.
void RemoveMergedCells (string range)
 Removes the defined merged cell range.
void RemoveRowHeight (int rowNumber)
 Removes the defined, non-standard row height.
void RemoveAllowedActionOnSheetProtection (SheetProtectionValue value)
 Removes an allowed action on the current worksheet or its cells.
void SetActiveStyle (Style style)
 Sets the active style of the worksheet. This style will be assigned to all later added cells.
void SetAutoFilter (int startColumn, int endColumn)
 Sets the column auto filter within the defined column range.
void SetAutoFilter (string range)
 Sets the column auto filter within the defined column range.
void SetColumnWidth (string columnAddress, float width)
 Sets the width of the passed column address.
void SetColumnWidth (int columnNumber, float width)
 Sets the width of the passed column number (zero-based).
Style SetColumnDefaultStyle (string columnAddress, Style style)
 Sets the default column style of the passed column address.
Style SetColumnDefaultStyle (int columnNumber, Style style)
 Sets the default column style of the passed column number (zero-based).
void SetCurrentCellAddress (int columnNumber, int rowNumber)
 Set the current cell address.
void SetCurrentCellAddress (string address)
 Set the current cell address.
void SetCurrentColumnNumber (int columnNumber)
 Sets the current column number (zero based).
void SetCurrentRowNumber (int rowNumber)
 Sets the current row number (zero based).
void AddSelectedCells (Range range)
 Adds a range to the selected cells on this worksheet.
void AddSelectedCells (Address startAddress, Address endAddress)
 Adds a range to the selected cells on this worksheet.
void AddSelectedCells (string rangeOrAddress)
 Adds a range or cell address to the selected cells on this worksheet.
void AddSelectedCells (Address address)
 Adds a single cell address to the selected cells on this worksheet.
void ClearSelectedCells ()
 Removes all cell selections of this worksheet.
void RemoveSelectedCells (Range range)
 Removes the given range from the selected cell ranges of this worksheet, if existing. If the passed range is overlapping the ranges of the selected cells, only the intersecting addresses will be removed.
void RemoveSelectedCells (String rangeOrAddress)
 Removes the given range or cell address from the selected cell ranges of this worksheet, if existing.
void RemoveSelectedCells (Address startAddress, Address endAddress)
 Removes the given range from the selected cell ranges of this worksheet, if existing.
void RemoveSelectedCells (Address address)
 Removes the given address from the selected cell ranges of this worksheet, if existing.
void SetSheetProtectionPassword (string password)
 Sets or removes the password for worksheet protection. If set, UseSheetProtection will be also set to true.
void SetRowHeight (int rowNumber, float height)
 Sets the height of the passed row number (zero-based).
void SetSheetName (string name)
 Validates and sets the worksheet name.
void SetSheetName (string name, bool sanitize)
 Sets the name of the worksheet.
void SetHorizontalSplit (float topPaneHeight, Address topLeftCell, WorksheetPane? activePane)
 Sets the horizontal split of the worksheet into two panes. The measurement in characters cannot be used to freeze panes.
void SetHorizontalSplit (int numberOfRowsFromTop, bool freeze, Address topLeftCell, WorksheetPane? activePane)
 Sets the horizontal split of the worksheet into two panes. The measurement in rows can be used to split and freeze panes.
void SetVerticalSplit (float leftPaneWidth, Address topLeftCell, WorksheetPane? activePane)
 Sets the vertical split of the worksheet into two panes. The measurement in characters cannot be used to freeze panes.
void SetVerticalSplit (int numberOfColumnsFromLeft, bool freeze, Address topLeftCell, WorksheetPane? activePane)
 Sets the vertical split of the worksheet into two panes. The measurement in columns can be used to split and freeze panes.
void SetSplit (int? numberOfColumnsFromLeft, int? numberOfRowsFromTop, bool freeze, Address topLeftCell, WorksheetPane? activePane)
 Sets the horizontal and vertical split of the worksheet into four panes. The measurement in rows and columns can be used to split and freeze panes.
void SetSplit (float? leftPaneWidth, float? topPaneHeight, Address topLeftCell, WorksheetPane? activePane)
 Sets the horizontal and vertical split of the worksheet into four panes. The measurement in characters cannot be used to freeze panes.
void ResetSplit ()
 Resets splitting of the worksheet into panes, as well as their freezing.
Worksheet Copy ()
 Creates a (dereferenced) deep copy of this worksheet.
void SetZoomFactor (SheetViewType sheetViewType, int zoomFactor)
 Sets a zoom factor for a given SheetViewType. If AutoZoomFactor, the zoom factor is set to automatic.

Static Public Member Functions

static string SanitizeWorksheetName (string input, Workbook workbook)
 Sanitizes a worksheet name.

Static Public Attributes

static readonly int MaxWorksheetNameLength = 31
 Maximum number of characters a worksheet name can have.
static readonly float DefaultWorksheetColumnWidth = 10f
 Default column width as constant.
static readonly float DefaultWorksheetRowHeight = 15f
 Default row height as constant.
static readonly int MaxColumnNumber = 16383
 Maximum column number (zero-based) as constant.
static readonly int MinColumnNumber = 0
 Minimum column number (zero-based) as constant.
static readonly float MinColumnWidth = 0f
 Minimum column width as constant.
static readonly float MinRowHeight = 0f
 Minimum row height as constant.
static readonly float MaxColumnWidth = 255f
 Maximum column width as constant.
static readonly int MaxRowNumber = 1048575
 Maximum row number (zero-based) as constant.
static readonly int MinRowNumber = 0
 Minimum row number (zero-based) as constant.
static readonly float MaxRowHeight = 409.5f
 Maximum row height as constant.
const int AutoZoomFactor = 0
 Automatic zoom factor of a worksheet.
const int MinZoomFactor = 10
 Minimum zoom factor of a worksheet. If set to this value, the zoom is set to automatic.
const int maxZoomFactor = 400
 Maximum zoom factor of a worksheet.

Properties

RangeAutoFilterRange [get]
 Gets the range of the auto-filter. Wrapped to Nullable to provide null as value. If null, no auto-filter is applied.
Dictionary< string, CellCells [get]
 Gets the cells of the worksheet as dictionary with the cell address as key and the cell object as value.
Dictionary< int, ColumnColumns [get]
 Gets all columns with non-standard properties, like auto filter applied or a special width as dictionary with the zero-based column index as key and the column object as value.
CellDirection CurrentCellDirection [get, set]
 Gets or sets the direction when using AddNextCell method.
float DefaultColumnWidth [get, set]
 Gets or sets the default column width.
float DefaultRowHeight [get, set]
 Gets or sets the default Row height.
Dictionary< int, bool > HiddenRows [get]
 Gets the hidden rows as dictionary with the zero-based row number as key and a boolean as value. True indicates hidden, false visible.
Dictionary< int, float > RowHeights [get]
 Gets defined row heights as dictionary with the zero-based row number as key and the height (float from 0 to 409.5) as value.
Dictionary< string, RangeMergedCells [get]
 Gets the merged cells (only references) as dictionary with the cell address as key and the range object as value.
List< RangeSelectedCells [get]
 Gets the cell ranges of selected cells of this worksheet. Returns ans empty list if no cells are selected.
int SheetID [get, set]
 Gets or sets the internal ID of the worksheet.
string SheetName [get, set]
 Gets or sets the name of the worksheet.
virtual IPassword SheetProtectionPassword [get, set]
 Password instance of the worksheet protection. If a password was set, the pain text representation and the hash can be read from the instance.
List< SheetProtectionValueSheetProtectionValues [get]
 Gets the list of SheetProtectionValues. These values define the allowed actions if the worksheet is protected.
bool UseSheetProtection [get, set]
 Gets or sets whether the worksheet is protected. If true, protection is enabled.
Workbook WorkbookReference [get, set]
 Gets or sets the Reference to the parent Workbook.
bool Hidden [get, set]
 gets or sets whether the worksheet is hidden. If true, the worksheet is not listed in the worksheet tabs of the workbook.
If the worksheet is not part of a workbook, or the only one in the workbook, an exception will be thrown.
If the worksheet is the selected one, and attempted to set hidden, an exception will be thrown. Define another selected worksheet prior to this call, in this case.
float? PaneSplitTopHeight [get]
 Gets the height of the upper, horizontal split pane, measured from the top of the window.
The value is nullable. If null, no horizontal split of the worksheet is applied.
The value is only applicable to split the worksheet into panes, but not to freeze them.
See also: PaneSplitAddress.
float? PaneSplitLeftWidth [get]
 Gets the width of the left, vertical split pane, measured from the left of the window.
The value is nullable. If null, no vertical split of the worksheet is applied
The value is only applicable to split the worksheet into panes, but not to freeze them.
See also: PaneSplitAddress.
bool? FreezeSplitPanes [get]
 Gets whether split panes are frozen.
The value is nullable. If null, no freezing is applied. This property also does not apply if PaneSplitAddress is null.
AddressPaneSplitTopLeftCell [get]
 Gets the Top Left cell address of the bottom right pane if applicable and splitting is applied.
The column is only relevant for vertical split, whereas the row component is only relevant for a horizontal split.
The value is nullable. If null, no splitting was defined.
AddressPaneSplitAddress [get]
 Gets the split address for frozen panes or if pane split was defined in number of columns and / or rows.
For vertical splits, only the column component is considered. For horizontal splits, only the row component is considered.
The value is nullable. If null, no frozen panes or split by columns / rows are applied to the worksheet. However, splitting can still be applied, if the value is defined in characters.
See also: PaneSplitLeftWidth and PaneSplitTopHeight for splitting in characters (without freezing).
WorksheetPaneActivePane [get]
 Gets the active Pane is splitting is applied.
The value is nullable. If null, no splitting was defined.
Style ActiveStyle [get]
 Gets the active Style of the worksheet. If null, no style is defined as active.
bool ShowGridLines [get, set]
 Gets or sets whether grid lines are visible on the current worksheet. Default is true.
bool ShowRowColumnHeaders [get, set]
 Gets or sets whether the column and row headers are visible on the current worksheet. Default is true.
bool ShowRuler [get, set]
 Gets or sets whether a ruler is displayed over the column headers. This value only applies if ViewType is set to SheetViewType.PageLayout. Default is true.
SheetViewType ViewType [get, set]
 Gets or sets how the current worksheet is displayed in the spreadsheet application (Excel).
int ZoomFactor [get, set]
 Gets or sets the zoom factor of the ViewType of the current worksheet. If AutoZoomFactor, the zoom factor is set to automatic.
Dictionary< SheetViewType, int > ZoomFactors [get]
 Gets all defined zoom factors per SheetViewType of the current worksheet. Use SetZoomFactor(SheetViewType, int) to define the values.

Detailed Description

Class representing a worksheet of a workbook.

Definition at line 25 of file Worksheet.cs.

Member Enumeration Documentation

◆ CellDirection

Enum to define the direction when using AddNextCell method.

Enumerator
ColumnToColumn 

The next cell will be on the same row (A1,B1,C1...).

RowToRow 

The next cell will be on the same column (A1,A2,A3...).

Disabled 

The address of the next cell will be not changed when adding a cell (for manual definition of cell addresses).

Definition at line 105 of file Worksheet.cs.

◆ SheetProtectionValue

Enum to define the possible protection types when protecting a worksheet.

Enumerator
Objects 

If selected, the user can edit objects if the worksheets is protected.

Scenarios 

If selected, the user can edit scenarios if the worksheets is protected.

FormatCells 

If selected, the user can format cells if the worksheets is protected.

FormatColumns 

If selected, the user can format columns if the worksheets is protected.

FormatRows 

If selected, the user can format rows if the worksheets is protected.

InsertColumns 

If selected, the user can insert columns if the worksheets is protected.

InsertRows 

If selected, the user can insert rows if the worksheets is protected.

InsertHyperlinks 

If selected, the user can insert hyper links if the worksheets is protected.

DeleteColumns 

If selected, the user can delete columns if the worksheets is protected.

DeleteRows 

If selected, the user can delete rows if the worksheets is protected.

SelectLockedCells 

If selected, the user can select locked cells if the worksheets is protected.

Sort 

If selected, the user can sort cells if the worksheets is protected.

AutoFilter 

If selected, the user can use auto filters if the worksheets is protected.

PivotTables 

If selected, the user can use pivot tables if the worksheets is protected.

SelectUnlockedCells 

If selected, the user can select unlocked cells if the worksheets is protected.

Definition at line 118 of file Worksheet.cs.

◆ SheetViewType

Enum to define how a worksheet is displayed in the spreadsheet application (Excel).

Enumerator
Normal 

The worksheet is displayed without pagination (default).

PageBreakPreview 

The worksheet is displayed with indicators where the page would break if it were printed.

PageLayout 

The worksheet is displayed like it would be printed.

Definition at line 171 of file Worksheet.cs.

◆ WorksheetPane

Enum to define the pane position or active pane in a slip worksheet.

Enumerator
BottomRight 

The pane is located in the bottom right of the split worksheet.

TopRight 

The pane is located in the top right of the split worksheet.

BottomLeft 

The pane is located in the bottom left of the split worksheet.

TopLeft 

The pane is located in the top left of the split worksheet.

Definition at line 156 of file Worksheet.cs.

Constructor & Destructor Documentation

◆ Worksheet() [1/3]

NanoXLSX.Worksheet.Worksheet ( )

Default Constructor.

Definition at line 533 of file Worksheet.cs.

◆ Worksheet() [2/3]

NanoXLSX.Worksheet.Worksheet ( string name)

Constructor with worksheet name.

Remarks
Note that the worksheet name is not checked and fully sanitized against other worksheets with this operation. This is later performed when the worksheet is added to the workbook

Definition at line 564 of file Worksheet.cs.

◆ Worksheet() [3/3]

NanoXLSX.Worksheet.Worksheet ( string name,
int id,
Workbook reference )

Constructor with name and sheet ID.

Parameters
nameName of the worksheet
idID of the worksheet (for internal use)
referenceReference to the parent Workbook

Definition at line 576 of file Worksheet.cs.

Member Function Documentation

◆ AddAllowedActionOnSheetProtection()

void NanoXLSX.Worksheet.AddAllowedActionOnSheetProtection ( SheetProtectionValue typeOfProtection)

Method to add allowed actions if the worksheet is protected. If one or more values are added, UseSheetProtection will be set to true.

Parameters
typeOfProtectionAllowed action on the worksheet or cells
Remarks
If SheetProtectionValue.SelectLockedCells is added, SheetProtectionValue.SelectUnlockedCells is added automatically

Definition at line 1583 of file Worksheet.cs.

◆ AddCell() [1/4]

void NanoXLSX.Worksheet.AddCell ( object value,
int columnNumber,
int rowNumber )

Adds an object to the defined cell address. If the type of the value does not match with one of the supported data types, it will be cast to a String. A prepared object of the type Cell will not be cast but adjusted.

Parameters
valueUnspecified value to insert
columnNumberColumn number (zero based)
rowNumberRow number (zero based)
Remarks
Recognized are the following data types: Cell (prepared object), string, int, double, float, long, DateTime, TimeSpan, bool. All other types will be cast into a string using the default ToString() method
Exceptions
RangeExceptionThrows a RangeException if the passed cell address is out of range

Definition at line 733 of file Worksheet.cs.

◆ AddCell() [2/4]

void NanoXLSX.Worksheet.AddCell ( object value,
int columnNumber,
int rowNumber,
Style style )

Adds an object to the defined cell address. If the type of the value does not match with one of the supported data types, it will be cast to a String. A prepared object of the type Cell will not be cast but adjusted.

Parameters
valueUnspecified value to insert
columnNumberColumn number (zero based)
rowNumberRow number (zero based)
styleStyle to apply on the cell
Remarks
Recognized are the following data types: Cell (prepared object), string, int, double, float, long, DateTime, TimeSpan, bool. All other types will be cast into a string using the default ToString() method
Exceptions
StyleExceptionThrows a StyleException if the passed style is malformed
RangeExceptionThrows a RangeException if the passed cell address is out of range

Definition at line 750 of file Worksheet.cs.

◆ AddCell() [3/4]

void NanoXLSX.Worksheet.AddCell ( object value,
string address )

Adds an object to the defined cell address. If the type of the value does not match with one of the supported data types, it will be cast to a String. A prepared object of the type Cell will not be cast but adjusted.

Parameters
valueUnspecified value to insert
addressCell address in the format A1 - XFD1048576
Remarks
Recognized are the following data types: Cell (prepared object), string, int, double, float, long, DateTime, TimeSpan, bool. All other types will be cast into a string using the default ToString() method
Exceptions
RangeExceptionThrows a RangeException if the passed cell address is out of range
NanoXLSX.Exceptions.FormatExceptionThrows a FormatException if the passed cell address is malformed

Definition at line 766 of file Worksheet.cs.

◆ AddCell() [4/4]

void NanoXLSX.Worksheet.AddCell ( object value,
string address,
Style style )

Adds an object to the defined cell address. If the type of the value does not match with one of the supported data types, it will be cast to a String. A prepared object of the type Cell will not be cast but adjusted.

Parameters
valueUnspecified value to insert
addressCell address in the format A1 - XFD1048576
styleStyle to apply on the cell
Remarks
Recognized are the following data types: Cell (prepared object), string, int, double, float, long, DateTime, TimeSpan, bool. All other types will be cast into a string using the default ToString() method
Exceptions
StyleExceptionThrows a StyleException if the passed style is malformed
RangeExceptionThrows a RangeException if the passed cell address is out of range
NanoXLSX.Exceptions.FormatExceptionThrows a FormatException if the passed cell address is malformed

Definition at line 786 of file Worksheet.cs.

◆ AddCellFormula() [1/4]

void NanoXLSX.Worksheet.AddCellFormula ( string formula,
int columnNumber,
int rowNumber )

Adds a cell formula as string to the defined cell address.

Parameters
formulaFormula to insert
columnNumberColumn number (zero based)
rowNumberRow number (zero based)
Exceptions
RangeExceptionThrows a RangeException if the passed cell address is out of range

Definition at line 839 of file Worksheet.cs.

◆ AddCellFormula() [2/4]

void NanoXLSX.Worksheet.AddCellFormula ( string formula,
int columnNumber,
int rowNumber,
Style style )

Adds a cell formula as string to the defined cell address.

Parameters
formulaFormula to insert
columnNumberColumn number (zero based)
rowNumberRow number (zero based)
styleStyle to apply on the cell
Exceptions
RangeExceptionThrows a RangeException if the passed cell address is out of range

Definition at line 853 of file Worksheet.cs.

◆ AddCellFormula() [3/4]

void NanoXLSX.Worksheet.AddCellFormula ( string formula,
string address )

Adds a cell formula as string to the defined cell address.

Parameters
formulaFormula to insert
addressCell address in the format A1 - XFD1048576
Exceptions
RangeExceptionThrows a RangeException if the passed cell address is out of range
NanoXLSX.Exceptions.FormatExceptionThrows a FormatException if the passed cell address is malformed

Definition at line 805 of file Worksheet.cs.

◆ AddCellFormula() [4/4]

void NanoXLSX.Worksheet.AddCellFormula ( string formula,
string address,
Style style )

Adds a cell formula as string to the defined cell address.

Parameters
formulaFormula to insert
addressCell address in the format A1 - XFD1048576
styleStyle to apply on the cell
Exceptions
StyleExceptionThrows a StyleException if the passed style was malformed
RangeExceptionThrows a RangeException if the passed cell address is out of range
NanoXLSX.Exceptions.FormatExceptionThrows a FormatException if the passed cell address is malformed

Definition at line 823 of file Worksheet.cs.

◆ AddCellRange() [1/4]

void NanoXLSX.Worksheet.AddCellRange ( IReadOnlyList< object > values,
Address startAddress,
Address endAddress )

Adds a list of object values to a defined cell range. If the type of the particular value does not match with one of the supported data types, it will be cast to a String. Prepared objects of the type Cell will not be cast but adjusted.

Parameters
valuesList of unspecified objects to insert
startAddressStart address
endAddressEnd address
Remarks
The data types in the passed list can be mixed. Recognized are the following data types: string, int, double, float, long, DateTime, TimeSpan, bool. All other types will be cast into a string using the default ToString() method
Exceptions
RangeExceptionThrows a RangeException if the number of cells resolved from the range differs from the number of passed values

Definition at line 896 of file Worksheet.cs.

◆ AddCellRange() [2/4]

void NanoXLSX.Worksheet.AddCellRange ( IReadOnlyList< object > values,
Address startAddress,
Address endAddress,
Style style )

Adds a list of object values to a defined cell range. If the type of the particular value does not match with one of the supported data types, it will be cast to a String. Prepared objects of the type Cell will not be cast but adjusted.

Parameters
valuesList of unspecified objects to insert
startAddressStart address
endAddressEnd address
styleStyle to apply on the all cells of the range
Remarks
The data types in the passed list can be mixed. Recognized are the following data types: Cell (prepared object), string, int, double, float, long, DateTime, TimeSpan, bool. All other types will be cast into a string using the default ToString() method
Exceptions
RangeExceptionThrows a RangeException if the number of cells resolved from the range differs from the number of passed values
StyleExceptionThrows a StyleException if the passed style is malformed

Definition at line 913 of file Worksheet.cs.

◆ AddCellRange() [3/4]

void NanoXLSX.Worksheet.AddCellRange ( IReadOnlyList< object > values,
string cellRange )

Adds a list of object values to a defined cell range. If the type of the particular value does not match with one of the supported data types, it will be cast to a String. Prepared objects of the type Cell will not be cast but adjusted.

Parameters
valuesList of unspecified objects to insert
cellRangeCell range as string in the format like A1:D1 or X10:X22
Remarks
The data types in the passed list can be mixed. Recognized are the following data types: Cell (prepared object), string, int, double, float, long, DateTime, TimeSpan, bool. All other types will be cast into a string using the default ToString() method
Exceptions
RangeExceptionThrows a RangeException if the number of cells resolved from the range differs from the number of passed values
NanoXLSX.Exceptions.FormatExceptionThrows a FormatException if the passed cell range is malformed

Definition at line 928 of file Worksheet.cs.

◆ AddCellRange() [4/4]

void NanoXLSX.Worksheet.AddCellRange ( IReadOnlyList< object > values,
string cellRange,
Style style )

Adds a list of object values to a defined cell range. If the type of the particular value does not match with one of the supported data types, it will be cast to a String. Prepared objects of the type Cell will not be cast but adjusted.

Parameters
valuesList of unspecified objects to insert
cellRangeCell range as string in the format like A1:D1 or X10:X22
styleStyle to apply on the all cells of the range
Remarks
The data types in the passed list can be mixed. Recognized are the following data types: Cell (prepared object), string, int, double, float, long, DateTime, TimeSpan, bool. All other types will be cast into a string using the default ToString() method
Exceptions
RangeExceptionThrows a RangeException if the number of cells resolved from the range differs from the number of passed values
StyleExceptionThrows a StyleException if the passed style is malformed
NanoXLSX.Exceptions.FormatExceptionThrows a FormatException if the passed cell range is malformed

Definition at line 946 of file Worksheet.cs.

◆ AddHiddenColumn() [1/2]

void NanoXLSX.Worksheet.AddHiddenColumn ( int columnNumber)

Sets the defined column as hidden.

Parameters
columnNumberColumn number to hide on the worksheet
Exceptions
RangeExceptionThrows a RangeException if the passed column number is out of range

Definition at line 1601 of file Worksheet.cs.

◆ AddHiddenColumn() [2/2]

void NanoXLSX.Worksheet.AddHiddenColumn ( string columnAddress)

Sets the defined column as hidden.

Parameters
columnAddressColumn address to hide on the worksheet
Exceptions
RangeExceptionThrows a RangeException if the passed column address is out of range

Definition at line 1611 of file Worksheet.cs.

◆ AddHiddenRow()

void NanoXLSX.Worksheet.AddHiddenRow ( int rowNumber)

Sets the defined row as hidden.

Parameters
rowNumberRow number to hide on the worksheet
Exceptions
RangeExceptionThrows a RangeException if the passed row number is out of range

Definition at line 1622 of file Worksheet.cs.

◆ AddNextCell() [1/2]

void NanoXLSX.Worksheet.AddNextCell ( object value)

Adds an object to the next cell position. If the type of the value does not match with one of the supported data types, it will be cast to a String. A prepared object of the type Cell will not be cast but adjusted.

Remarks
Recognized are the following data types: Cell (prepared object), string, int, double, float, long, DateTime, TimeSpan, bool. All other types will be cast into a string using the default ToString() method
Parameters
valueUnspecified value to insert
Exceptions
RangeExceptionThrows a RangeException if the next cell is out of range (on row or column)

Definition at line 596 of file Worksheet.cs.

◆ AddNextCell() [2/2]

void NanoXLSX.Worksheet.AddNextCell ( object value,
Style style )

Adds an object to the next cell position. If the type of the value does not match with one of the supported data types, it will be cast to a String. A prepared object of the type Cell will not be cast but adjusted.

Remarks
Recognized are the following data types: Cell (prepared object), string, int, double, float, long, DateTime, TimeSpan, bool. All other types will be cast into a string using the default ToString() method
Parameters
valueUnspecified value to insert
styleStyle object to apply on this cell
Exceptions
RangeExceptionThrows a RangeException if the next cell is out of range (on row or column)
StyleExceptionThrows a StyleException if the default style was malformed

Definition at line 612 of file Worksheet.cs.

◆ AddNextCellFormula() [1/2]

void NanoXLSX.Worksheet.AddNextCellFormula ( string formula)

Adds a formula as string to the next cell position.

Parameters
formulaFormula to insert
Exceptions
RangeExceptionTrows a RangeException if the next cell is out of range (on row or column)

Definition at line 864 of file Worksheet.cs.

◆ AddNextCellFormula() [2/2]

void NanoXLSX.Worksheet.AddNextCellFormula ( string formula,
Style style )

Adds a formula as string to the next cell position.

Parameters
formulaFormula to insert
styleStyle to apply on the cell
Exceptions
RangeExceptionTrows a RangeException if the next cell is out of range (on row or column)

Definition at line 876 of file Worksheet.cs.

◆ AddSelectedCells() [1/4]

void NanoXLSX.Worksheet.AddSelectedCells ( Address address)

Adds a single cell address to the selected cells on this worksheet.

Parameters
addressCell address to add

Definition at line 2305 of file Worksheet.cs.

◆ AddSelectedCells() [2/4]

void NanoXLSX.Worksheet.AddSelectedCells ( Address startAddress,
Address endAddress )

Adds a range to the selected cells on this worksheet.

Parameters
startAddressStart address of the range
endAddressEnd address of the range

Definition at line 2283 of file Worksheet.cs.

◆ AddSelectedCells() [3/4]

void NanoXLSX.Worksheet.AddSelectedCells ( Range range)

Adds a range to the selected cells on this worksheet.

Parameters
rangeCell range to add

Definition at line 2273 of file Worksheet.cs.

◆ AddSelectedCells() [4/4]

void NanoXLSX.Worksheet.AddSelectedCells ( string rangeOrAddress)

Adds a range or cell address to the selected cells on this worksheet.

Parameters
rangeOrAddressCell range or address to add

Definition at line 2292 of file Worksheet.cs.

◆ CellsByValue()

List< Cell > NanoXLSX.Worksheet.CellsByValue ( object searchValue)

Searches for cells that contain the specified value and returns a list of these cells.

Parameters
searchValueThe value to search for.
Returns
A list of cells that contain the specified value.

Definition at line 1549 of file Worksheet.cs.

◆ ClearActiveStyle()

void NanoXLSX.Worksheet.ClearActiveStyle ( )

Clears the active style of the worksheet. All later added calls will contain no style unless another active style is set.

Definition at line 1630 of file Worksheet.cs.

◆ ClearSelectedCells()

void NanoXLSX.Worksheet.ClearSelectedCells ( )

Removes all cell selections of this worksheet.

Definition at line 2313 of file Worksheet.cs.

◆ Copy()

Worksheet NanoXLSX.Worksheet.Copy ( )

Creates a (dereferenced) deep copy of this worksheet.

Remarks
Not considered in the copy are the internal ID, the worksheet name and the workbook reference. Since styles are managed in a shared repository, no dereferencing is applied (Styles are not deep-copied). Use Workbook.CopyWorksheetTo(Worksheet, string, Workbook, bool) or Workbook.CopyWorksheetIntoThis(Worksheet, string, bool) to add a copy of worksheet to a workbook. These methods will set the internal ID, name and workbook reference.
Returns
Copy of this worksheet

Definition at line 2596 of file Worksheet.cs.

◆ FirstCellByValue()

Cell NanoXLSX.Worksheet.FirstCellByValue ( object searchValue)

Searches for the first occurrence of the value.

Parameters
searchValueThe value to search for.
Returns
The first cell containing the searched value or null if the value was not found

Definition at line 1524 of file Worksheet.cs.

◆ FirstOrDefaultCell()

Cell NanoXLSX.Worksheet.FirstOrDefaultCell ( Func< Cell, bool > predicate)

Searches for the first occurrence of the expression. Example: var cell = worksheet.FindCell(c => c.Value?.ToString().Contains("searchValue"));.

Parameters
predicate
Returns
The first cell containing the searched value or null if the value was not found

Definition at line 1538 of file Worksheet.cs.

◆ GetCell() [1/2]

Cell NanoXLSX.Worksheet.GetCell ( Address address)

Gets the cell of the specified address.

Parameters
addressAddress of the cell
Returns
Cell object
Exceptions
WorksheetExceptionTrows a WorksheetException if the cell was not found on the cell table of this worksheet

Definition at line 1642 of file Worksheet.cs.

◆ GetCell() [2/2]

Cell NanoXLSX.Worksheet.GetCell ( int columnNumber,
int rowNumber )

Gets the cell of the specified column and row number (zero-based).

Parameters
columnNumberColumn number of the cell
rowNumberRow number of the cell
Returns
Cell object
Exceptions
WorksheetExceptionTrows a WorksheetException if the cell was not found on the cell table of this worksheet

Definition at line 1658 of file Worksheet.cs.

◆ GetColumn() [1/2]

IReadOnlyList< Cell > NanoXLSX.Worksheet.GetColumn ( int columnNumber)

Gets a column as list of cell objects.

Parameters
columnNumberColumn number (zero-based)
Returns
List of cell objects. If the column doesn't exist, an empty list is returned

Definition at line 1743 of file Worksheet.cs.

◆ GetColumn() [2/2]

IReadOnlyList< Cell > NanoXLSX.Worksheet.GetColumn ( string columnAddress)

Gets a column as list of cell objects.

Parameters
columnAddressColumn address
Exceptions
RangeExceptionA range exception is thrown if the address is not valid
Returns
List of cell objects. If the column doesn't exist, an empty list is returned

Definition at line 1732 of file Worksheet.cs.

◆ GetCurrentColumnNumber()

int NanoXLSX.Worksheet.GetCurrentColumnNumber ( )

Gets the current column number (zero based).

Returns
Column number (zero-based)

Definition at line 1761 of file Worksheet.cs.

◆ GetCurrentRowNumber()

int NanoXLSX.Worksheet.GetCurrentRowNumber ( )

Gets the current row number (zero based).

Returns
Row number (zero-based)

Definition at line 1770 of file Worksheet.cs.

◆ GetFirstCellAddress()

Address? NanoXLSX.Worksheet.GetFirstCellAddress ( )

Gets the first existing cell in the current worksheet (bottom right).

Returns
Nullable Cell Address. If no cell address could be determined, null will be returned
Remarks
GetFirstCellAddress() will not return the first cell with data in any case. If there is a formatted but empty cell (or many) before the first cell with data, GetLastCellAddress() will return the address of this empty cell. Use GetFirstDataCellAddress in this case.

Definition at line 1236 of file Worksheet.cs.

◆ GetFirstColumnNumber()

int NanoXLSX.Worksheet.GetFirstColumnNumber ( )

Gets the first existing column number in the current worksheet (zero-based).

Returns
Zero-based column number. In case of an empty worksheet, -1 will be returned
Remarks
GetFirstColumnNumber() will not return the first column with data in any case. If there is a formatted but empty cell (or many) before the first cell with data, GetFirstColumnNumber() will return the column number of this empty cell. Use GetFirstDataColumnNumber in this case.

Definition at line 1108 of file Worksheet.cs.

◆ GetFirstDataCellAddress()

Address? NanoXLSX.Worksheet.GetFirstDataCellAddress ( )

Gets the first existing cell with data in the current worksheet (bottom right).

Returns
Nullable Cell Address. If no cell address could be determined, null will be returned
Remarks
GetFirstDataCellAddress() will ignore formatted but empty cells before the first cell with data. If you want the first defined cell, use GetFirstCellAddress instead.

Definition at line 1253 of file Worksheet.cs.

◆ GetFirstDataColumnNumber()

int NanoXLSX.Worksheet.GetFirstDataColumnNumber ( )

Gets the first existing column number with data in the current worksheet (zero-based).

Returns
Zero-based column number. In case of an empty worksheet, -1 will be returned
Remarks
GetFirstDataColumnNumber() will ignore formatted but empty cells before the first column with data. If you want the first defined column, use GetFirstColumnNumber instead.

Definition at line 1119 of file Worksheet.cs.

◆ GetFirstDataRowNumber()

int NanoXLSX.Worksheet.GetFirstDataRowNumber ( )

Gets the first existing row number with data in the current worksheet (zero-based).

Returns
Zero-based row number. In case of an empty worksheet, -1 will be returned
Remarks
GetFirstDataRowNumber() will ignore formatted but empty cells before the first row with data. If you want the first defined row, use GetFirstRowNumber instead.

Definition at line 1141 of file Worksheet.cs.

◆ GetFirstRowNumber()

int NanoXLSX.Worksheet.GetFirstRowNumber ( )

Gets the first existing row number in the current worksheet (zero-based).

Returns
Zero-based row number. In case of an empty worksheet, -1 will be returned
Remarks
GetFirstRowNumber() will not return the first row with data in any case. If there is a formatted but empty cell (or many) before the first cell with data, GetFirstRowNumber() will return the row number of this empty cell. Use GetFirstDataRowNumber in this case.

Definition at line 1130 of file Worksheet.cs.

◆ GetLastCellAddress()

Address? NanoXLSX.Worksheet.GetLastCellAddress ( )

Gets the last existing cell in the current worksheet (bottom right).

Returns
Nullable Cell Address. If no cell address could be determined, null will be returned
Remarks
GetLastCellAddress() will not return the last cell with data in any case. If there is a formatted (or with definitions of hidden states, AutoFilters, heights or widths) but empty cell (or many) after the last cell with data, GetLastCellAddress() will return the address of this empty cell. Use GetLastDataCellAddress in this case.

Definition at line 1201 of file Worksheet.cs.

◆ GetLastColumnNumber()

int NanoXLSX.Worksheet.GetLastColumnNumber ( )

Gets the last existing column number in the current worksheet (zero-based).

Returns
Zero-based column number. In case of an empty worksheet, -1 will be returned
Remarks
GetLastColumnNumber() will not return the last column with data in any case. If there is a formatted (or with the definition of AutoFilter, column width or hidden state) but empty cell (or many) after the last cell with data, GetLastColumnNumber() will return the column number of this empty cell. Use GetLastDataColumnNumber in this case.

Definition at line 1153 of file Worksheet.cs.

◆ GetLastDataCellAddress()

Address? NanoXLSX.Worksheet.GetLastDataCellAddress ( )

Gets the last existing cell with data in the current worksheet (bottom right).

Returns
Nullable Cell Address. If no cell address could be determined, null will be returned
Remarks
GetLastDataCellAddress() will ignore formatted (or with definitions of hidden states, AutoFilters, heights or widths) but empty cells after the last cell with data. If you want the last defined cell, use GetLastCellAddress instead.

Definition at line 1219 of file Worksheet.cs.

◆ GetLastDataColumnNumber()

int NanoXLSX.Worksheet.GetLastDataColumnNumber ( )

Gets the last existing column number with data in the current worksheet (zero-based).

Returns
Zero-based column number. in case of an empty worksheet, -1 will be returned
Remarks
GetLastDataColumnNumber() will ignore formatted (or with the definition of AutoFilter, column width or hidden state) but empty cells after the last column with data. If you want the last defined column, use GetLastColumnNumber instead.

Definition at line 1164 of file Worksheet.cs.

◆ GetLastDataRowNumber()

int NanoXLSX.Worksheet.GetLastDataRowNumber ( )

Gets the last existing row number with data in the current worksheet (zero-based).

Returns
Zero-based row number. in case of an empty worksheet, -1 will be returned
Remarks
GetLastDataColumnNumber() will ignore formatted (or with the definition of row height or hidden state) but empty cells after the last column with data. If you want the last defined column, use GetLastRowNumber instead.

Definition at line 1188 of file Worksheet.cs.

◆ GetLastRowNumber()

int NanoXLSX.Worksheet.GetLastRowNumber ( )

Gets the last existing row number in the current worksheet (zero-based).

Returns
Zero-based row number. In case of an empty worksheet, -1 will be returned
Remarks
GetLastRowNumber() will not return the last row with data in any case. If there is a formatted (or with the definition of row height or hidden state) but empty cell (or many) after the last cell with data, GetLastRowNumber() will return the row number of this empty cell. Use GetLastDataRowNumber in this case.

Definition at line 1176 of file Worksheet.cs.

◆ GetRow()

IReadOnlyList< Cell > NanoXLSX.Worksheet.GetRow ( int rowNumber)

Gets a row as list of cell objects.

Parameters
rowNumberRow number (zero-based)
Returns
List of cell objects. If the row doesn't exist, an empty list is returned

Definition at line 1712 of file Worksheet.cs.

◆ GoToNextColumn() [1/2]

void NanoXLSX.Worksheet.GoToNextColumn ( )

Moves the current position to the next column.

Definition at line 1778 of file Worksheet.cs.

◆ GoToNextColumn() [2/2]

void NanoXLSX.Worksheet.GoToNextColumn ( int numberOfColumns,
bool keepRowPosition = false )

Moves the current position to the next column with the number of cells to move.

Parameters
numberOfColumnsNumber of columns to move
keepRowPositionIf true, the row position is preserved, otherwise set to 0
Remarks
The value can also be negative. However, resulting column numbers below 0 or above 16383 will cause an exception

Definition at line 1791 of file Worksheet.cs.

◆ GoToNextRow() [1/2]

void NanoXLSX.Worksheet.GoToNextRow ( )

Moves the current position to the next row (use for a new line).

Definition at line 1804 of file Worksheet.cs.

◆ GoToNextRow() [2/2]

void NanoXLSX.Worksheet.GoToNextRow ( int numberOfRows,
bool keepColumnPosition = false )

Moves the current position to the next row with the number of cells to move (use for a new line).

Parameters
numberOfRowsNumber of rows to move
keepColumnPositionIf true, the column position is preserved, otherwise set to 0
Remarks
The value can also be negative. However, resulting row numbers below 0 or above 1048575 will cause an exception

Definition at line 1817 of file Worksheet.cs.

◆ HasCell() [1/2]

bool NanoXLSX.Worksheet.HasCell ( Address address)

Gets whether the specified address exists in the worksheet. Existing means that a value was stored at the address.

Parameters
addressAddress to check
Returns
true if the cell exists, otherwise false.

Definition at line 1670 of file Worksheet.cs.

◆ HasCell() [2/2]

bool NanoXLSX.Worksheet.HasCell ( int columnNumber,
int rowNumber )

Gets whether the specified address exists in the worksheet. Existing means that a value was stored at the address.

Parameters
columnNumberColumn number of the cell to check (zero-based)
rowNumberRow number of the cell to check (zero-based)
Returns
true if the cell exists, otherwise false.
Exceptions
RangeExceptionA RangeException is thrown if the column or row number is invalid

Definition at line 1684 of file Worksheet.cs.

◆ InsertColumn()

void NanoXLSX.Worksheet.InsertColumn ( int columnNumber,
int numberOfNewColumns )

Inserts 'count' columns right of the specified 'columnNumber'. Existing cells are moved to the right by the number of new columns. The inserted, new columns inherits the style of the original cell at the defined column number. The inserted cells are empty. The values can be set later.

Formulas are not adjusted

Parameters
columnNumberColumn number right which the new column(s) will be inserted.
numberOfNewColumnsNumber of columns to insert.

Definition at line 1476 of file Worksheet.cs.

◆ InsertRow()

void NanoXLSX.Worksheet.InsertRow ( int rowNumber,
int numberOfNewRows )

Inserts 'count' rows below the specified 'rowNumber'. Existing cells are moved down by the number of new rows. The inserted, new rows inherits the style of the original cell at the defined row number. The inserted cells are empty. The values can be set later.

Formulas / references are not adjusted

Parameters
rowNumberRow number below which the new row(s) will be inserted.
numberOfNewRowsNumber of rows to insert.

Definition at line 1421 of file Worksheet.cs.

◆ MergeCells() [1/3]

string NanoXLSX.Worksheet.MergeCells ( Address startAddress,
Address endAddress )

Merges the defined cell range.

Parameters
startAddressStart address of the merged cell range
endAddressEnd address of the merged cell range
Returns
Returns the validated range of the merged cells (e.g. 'A1:B12')
Exceptions
RangeExceptionThrows a RangeException if one of the passed cell addresses is out of range or if one or more cell addresses are already occupied in another merge range

Definition at line 1858 of file Worksheet.cs.

◆ MergeCells() [2/3]

string NanoXLSX.Worksheet.MergeCells ( Range cellRange)

Merges the defined cell range.

Parameters
cellRangeRange to merge
Returns
Returns the validated range of the merged cells (e.g. 'A1:B12')
Exceptions
RangeExceptionThrows a RangeException if the passed cell range is out of range

Definition at line 1833 of file Worksheet.cs.

◆ MergeCells() [3/3]

string NanoXLSX.Worksheet.MergeCells ( string cellRange)

Merges the defined cell range.

Parameters
cellRangeRange to merge (e.g. 'A1:B12')
Returns
Returns the validated range of the merged cells (e.g. 'A1:B12')
Exceptions
RangeExceptionThrows a RangeException if the passed cell range is out of range
NanoXLSX.Exceptions.FormatExceptionThrows a FormatException if the passed cell range is malformed

Definition at line 1845 of file Worksheet.cs.

◆ RemoveAllowedActionOnSheetProtection()

void NanoXLSX.Worksheet.RemoveAllowedActionOnSheetProtection ( SheetProtectionValue value)

Removes an allowed action on the current worksheet or its cells.

Parameters
valueAllowed action on the worksheet or cells

Definition at line 2062 of file Worksheet.cs.

◆ RemoveAutoFilter()

void NanoXLSX.Worksheet.RemoveAutoFilter ( )

Removes auto filters from the worksheet.

Definition at line 1981 of file Worksheet.cs.

◆ RemoveCell() [1/2]

bool NanoXLSX.Worksheet.RemoveCell ( int columnNumber,
int rowNumber )

Removes a previous inserted cell at the defined address.

Parameters
columnNumberColumn number (zero based)
rowNumberRow number (zero based)
Returns
Returns true if the cell could be removed (existed), otherwise false (did not exist)
Exceptions
RangeExceptionThrows a RangeException if the passed cell address is out of range

Definition at line 989 of file Worksheet.cs.

◆ RemoveCell() [2/2]

bool NanoXLSX.Worksheet.RemoveCell ( string address)

Removes a previous inserted cell at the defined address.

Parameters
addressCell address in the format A1 - XFD1048576
Returns
Returns true if the cell could be removed (existed), otherwise false (did not exist)
Exceptions
RangeExceptionThrows a RangeException if the passed cell address is out of range
NanoXLSX.Exceptions.FormatExceptionThrows a FormatException if the passed cell address is malformed

Definition at line 1002 of file Worksheet.cs.

◆ RemoveHiddenColumn() [1/2]

void NanoXLSX.Worksheet.RemoveHiddenColumn ( int columnNumber)

Sets a previously defined, hidden column as visible again.

Parameters
columnNumberColumn number to make visible again
Exceptions
RangeExceptionThrows a RangeException if the passed column number is out of range

Definition at line 1991 of file Worksheet.cs.

◆ RemoveHiddenColumn() [2/2]

void NanoXLSX.Worksheet.RemoveHiddenColumn ( string columnAddress)

Sets a previously defined, hidden column as visible again.

Parameters
columnAddressColumn address to make visible again
Exceptions
RangeExceptionThrows a RangeException if the column address out of range

Definition at line 2001 of file Worksheet.cs.

◆ RemoveHiddenRow()

void NanoXLSX.Worksheet.RemoveHiddenRow ( int rowNumber)

Sets a previously defined, hidden row as visible again.

Parameters
rowNumberRow number to hide on the worksheet
Exceptions
RangeExceptionThrows a RangeException if the passed row number is out of range

Definition at line 2012 of file Worksheet.cs.

◆ RemoveMergedCells()

void NanoXLSX.Worksheet.RemoveMergedCells ( string range)

Removes the defined merged cell range.

Parameters
rangeCell range to remove the merging
Exceptions
RangeExceptionThrows a RangeException if the passed cell range was not merged earlier

Definition at line 2022 of file Worksheet.cs.

◆ RemoveRowHeight()

void NanoXLSX.Worksheet.RemoveRowHeight ( int rowNumber)

Removes the defined, non-standard row height.

Parameters
rowNumberRow number (zero-based)

Definition at line 2050 of file Worksheet.cs.

◆ RemoveSelectedCells() [1/4]

void NanoXLSX.Worksheet.RemoveSelectedCells ( Address address)

Removes the given address from the selected cell ranges of this worksheet, if existing.

Parameters
addressAddress of the range to remove

Definition at line 2355 of file Worksheet.cs.

◆ RemoveSelectedCells() [2/4]

void NanoXLSX.Worksheet.RemoveSelectedCells ( Address startAddress,
Address endAddress )

Removes the given range from the selected cell ranges of this worksheet, if existing.

Parameters
startAddressStart address of the range to remove
endAddressEnd address of the range to remove

Definition at line 2346 of file Worksheet.cs.

◆ RemoveSelectedCells() [3/4]

void NanoXLSX.Worksheet.RemoveSelectedCells ( Range range)

Removes the given range from the selected cell ranges of this worksheet, if existing. If the passed range is overlapping the ranges of the selected cells, only the intersecting addresses will be removed.

Parameters
rangeRange to remove

Definition at line 2323 of file Worksheet.cs.

◆ RemoveSelectedCells() [4/4]

void NanoXLSX.Worksheet.RemoveSelectedCells ( String rangeOrAddress)

Removes the given range or cell address from the selected cell ranges of this worksheet, if existing.

Parameters
rangeOrAddressRange or cell address to remove

Definition at line 2332 of file Worksheet.cs.

◆ ReplaceCellValue()

int NanoXLSX.Worksheet.ReplaceCellValue ( object oldValue,
object newValue )

Replaces all occurrences of 'oldValue' with 'newValue' and returns the number of replacements.

Parameters
oldValueOld value
newValueNew value that should replace the old one
Returns
Count of replaced Cell values

Definition at line 1563 of file Worksheet.cs.

◆ ResetColumn()

void NanoXLSX.Worksheet.ResetColumn ( int columnNumber)

Resets the defined column, if existing. The corresponding instance will be removed from Columns.

Remarks
If the column is inside an autoFilter-Range, the column cannot be entirely removed from Columns. The hidden state will be set to false and width to default, in this case.
Parameters
columnNumberColumn number to reset (zero-based)

Definition at line 1694 of file Worksheet.cs.

◆ ResetSplit()

void NanoXLSX.Worksheet.ResetSplit ( )

Resets splitting of the worksheet into panes, as well as their freezing.

Definition at line 2577 of file Worksheet.cs.

◆ SanitizeWorksheetName()

string NanoXLSX.Worksheet.SanitizeWorksheetName ( string input,
Workbook workbook )
static

Sanitizes a worksheet name.

Parameters
inputName to sanitize
workbookWorkbook reference
Exceptions
WorksheetExceptionA WorksheetException is thrown if the workbook reference is null, since all worksheets have to be considered during sanitation
Returns
Name of the sanitized worksheet

Definition at line 2698 of file Worksheet.cs.

◆ SetActiveStyle()

void NanoXLSX.Worksheet.SetActiveStyle ( Style style)

Sets the active style of the worksheet. This style will be assigned to all later added cells.

Parameters
styleStyle to set as active style

Definition at line 2074 of file Worksheet.cs.

◆ SetAutoFilter() [1/2]

void NanoXLSX.Worksheet.SetAutoFilter ( int startColumn,
int endColumn )

Sets the column auto filter within the defined column range.

Parameters
startColumnColumn number with the first appearance of an auto filter drop down
endColumnColumn number with the last appearance of an auto filter drop down
Exceptions
RangeExceptionThrows a RangeException if the start or end address out of range

Definition at line 2093 of file Worksheet.cs.

◆ SetAutoFilter() [2/2]

void NanoXLSX.Worksheet.SetAutoFilter ( string range)

Sets the column auto filter within the defined column range.

Parameters
rangeRange to apply auto filter on. The range could be 'A1:C10' for instance. The end row will be recalculated automatically when saving the file
Exceptions
RangeExceptionThrows a RangeException if the passed range out of range
NanoXLSX.Exceptions.FormatExceptionThrows a FormatException if the passed range is malformed

Definition at line 2113 of file Worksheet.cs.

◆ SetColumnDefaultStyle() [1/2]

Style NanoXLSX.Worksheet.SetColumnDefaultStyle ( int columnNumber,
Style style )

Sets the default column style of the passed column number (zero-based).

Parameters
columnNumberColumn number (zero-based, from 0 to 16383)
styleStyle to set as default. If null, the style is cleared
Returns
Assigned style or null if cleared
Exceptions
RangeExceptionThrows a RangeException:
a) If the passed column number is out of range
b) if the column width is out of range (0 - 255.0)

Definition at line 2205 of file Worksheet.cs.

◆ SetColumnDefaultStyle() [2/2]

Style NanoXLSX.Worksheet.SetColumnDefaultStyle ( string columnAddress,
Style style )

Sets the default column style of the passed column address.

Parameters
columnAddressColumn address (A - XFD)
styleStyle to set as default. If null, the style is cleared
Returns
Assigned style or null if cleared
Exceptions
RangeExceptionThrows a RangeException:
a) If the passed column address is out of range
b) if the column width is out of range (0 - 255.0)

Definition at line 2193 of file Worksheet.cs.

◆ SetColumnWidth() [1/2]

void NanoXLSX.Worksheet.SetColumnWidth ( int columnNumber,
float width )

Sets the width of the passed column number (zero-based).

Parameters
columnNumberColumn number (zero-based, from 0 to 16383)
widthWidth from 0 to 255.0
Exceptions
RangeExceptionThrows a RangeException:
a) If the passed column number is out of range
b) if the column width is out of range (0 - 255.0)

Definition at line 2165 of file Worksheet.cs.

◆ SetColumnWidth() [2/2]

void NanoXLSX.Worksheet.SetColumnWidth ( string columnAddress,
float width )

Sets the width of the passed column address.

Parameters
columnAddressColumn address (A - XFD)
widthWidth from 0 to 255.0
Exceptions
RangeExceptionThrows a RangeException:
a) If the passed column address is out of range
b) if the column width is out of range (0 - 255.0)

Definition at line 2153 of file Worksheet.cs.

◆ SetCurrentCellAddress() [1/2]

void NanoXLSX.Worksheet.SetCurrentCellAddress ( int columnNumber,
int rowNumber )

Set the current cell address.

Parameters
columnNumberColumn number (zero based)
rowNumberRow number (zero based)
Exceptions
RangeExceptionThrows a RangeException if one of the passed cell addresses is out of range

Definition at line 2227 of file Worksheet.cs.

◆ SetCurrentCellAddress() [2/2]

void NanoXLSX.Worksheet.SetCurrentCellAddress ( string address)

Set the current cell address.

Parameters
addressCell address in the format A1 - XFD1048576
Exceptions
RangeExceptionThrows a RangeException if the passed cell address is out of range
NanoXLSX.Exceptions.FormatExceptionThrows a FormatException if the passed cell address is malformed

Definition at line 2239 of file Worksheet.cs.

◆ SetCurrentColumnNumber()

void NanoXLSX.Worksheet.SetCurrentColumnNumber ( int columnNumber)

Sets the current column number (zero based).

Parameters
columnNumberColumn number (zero based)
Exceptions
RangeExceptionThrows a RangeException if the number is out of the valid range. Range is from 0 to 16383 (16384 columns)

Definition at line 2252 of file Worksheet.cs.

◆ SetCurrentRowNumber()

void NanoXLSX.Worksheet.SetCurrentRowNumber ( int rowNumber)

Sets the current row number (zero based).

Parameters
rowNumberRow number (zero based)
Exceptions
RangeExceptionThrows a RangeException if the number is out of the valid range. Range is from 0 to 1048575 (1048576 rows)

Definition at line 2263 of file Worksheet.cs.

◆ SetHorizontalSplit() [1/2]

void NanoXLSX.Worksheet.SetHorizontalSplit ( float topPaneHeight,
Address topLeftCell,
WorksheetPane? activePane )

Sets the horizontal split of the worksheet into two panes. The measurement in characters cannot be used to freeze panes.

Parameters
topPaneHeightHeight (similar to row height) from top of the worksheet to the split line in characters
topLeftCellTop Left cell address of the bottom right pane (if applicable). Only the row component is important in a horizontal split
activePaneActive pane in the split window.
The parameter is nullable

Definition at line 2476 of file Worksheet.cs.

◆ SetHorizontalSplit() [2/2]

void NanoXLSX.Worksheet.SetHorizontalSplit ( int numberOfRowsFromTop,
bool freeze,
Address topLeftCell,
WorksheetPane? activePane )

Sets the horizontal split of the worksheet into two panes. The measurement in rows can be used to split and freeze panes.

Parameters
numberOfRowsFromTopNumber of rows from top of the worksheet to the split line. The particular row heights are considered
freezeIf true, all panes are frozen, otherwise remains movable
topLeftCellTop Left cell address of the bottom right pane (if applicable). Only the row component is important in a horizontal split
activePaneActive pane in the split window.
The parameter is nullable
Exceptions
WorksheetExceptionWorksheetException Thrown if the row number of the top left cell is smaller the split panes number of rows from top, if freeze is applied

Definition at line 2489 of file Worksheet.cs.

◆ SetRowHeight()

void NanoXLSX.Worksheet.SetRowHeight ( int rowNumber,
float height )

Sets the height of the passed row number (zero-based).

Parameters
rowNumberRow number (zero-based, 0 to 1048575)
heightHeight from 0 to 409.5
Exceptions
RangeExceptionThrows a RangeException:
a) If the passed row number is out of range
b) if the row height is out of range (0 - 409.5)

Definition at line 2384 of file Worksheet.cs.

◆ SetSheetName() [1/2]

void NanoXLSX.Worksheet.SetSheetName ( string name)

Validates and sets the worksheet name.

Parameters
nameName to set
Exceptions
NanoXLSX.Exceptions.FormatExceptionThrows a FormatException if the worksheet name is too long (max. 31) or contains illegal characters [ ] * ? / </exception>

Definition at line 2432 of file Worksheet.cs.

◆ SetSheetName() [2/2]

void NanoXLSX.Worksheet.SetSheetName ( string name,
bool sanitize )

Sets the name of the worksheet.

Parameters
nameName of the worksheet
sanitizeIf true, the filename will be sanitized automatically according to the specifications of Excel
Exceptions
WorksheetExceptionWorksheetException Thrown if no workbook is referenced. This information is necessary to determine whether the name already exists

Definition at line 2457 of file Worksheet.cs.

◆ SetSheetProtectionPassword()

void NanoXLSX.Worksheet.SetSheetProtectionPassword ( string password)

Sets or removes the password for worksheet protection. If set, UseSheetProtection will be also set to true.

Parameters
passwordPassword (UTF-8) to protect the worksheet. If the password is null or empty, no password will be used

Definition at line 2364 of file Worksheet.cs.

◆ SetSplit() [1/2]

void NanoXLSX.Worksheet.SetSplit ( float? leftPaneWidth,
float? topPaneHeight,
Address topLeftCell,
WorksheetPane? activePane )

Sets the horizontal and vertical split of the worksheet into four panes. The measurement in characters cannot be used to freeze panes.

Parameters
leftPaneWidthWidth (similar to column width) from left of the worksheet to the split line in characters.
The parameter is nullable. If left null, the method acts identical to SetHorizontalSplit(float, Address, WorksheetPane?)
topPaneHeightHeight (similar to row height) from top of the worksheet to the split line in characters.
The parameter is nullable. If left null, the method acts identical to SetVerticalSplit(float, Address, WorksheetPane?)
topLeftCellTop Left cell address of the bottom right pane (if applicable)
activePaneActive pane in the split window.
The parameter is nullable

Definition at line 2564 of file Worksheet.cs.

◆ SetSplit() [2/2]

void NanoXLSX.Worksheet.SetSplit ( int? numberOfColumnsFromLeft,
int? numberOfRowsFromTop,
bool freeze,
Address topLeftCell,
WorksheetPane? activePane )

Sets the horizontal and vertical split of the worksheet into four panes. The measurement in rows and columns can be used to split and freeze panes.

Parameters
numberOfColumnsFromLeftNumber of columns from left of the worksheet to the split line. The particular column widths are considered.
The parameter is nullable. If left null, the method acts identical to SetHorizontalSplit(int, bool, Address, WorksheetPane?)
numberOfRowsFromTopNumber of rows from top of the worksheet to the split line. The particular row heights are considered.
The parameter is nullable. If left null, the method acts identical to SetVerticalSplit(int, bool, Address, WorksheetPane?)
freezeIf true, all panes are frozen, otherwise remains movable
topLeftCellTop Left cell address of the bottom right pane (if applicable)
activePaneActive pane in the split window.
The parameter is nullable
Exceptions
WorksheetExceptionWorksheetException Thrown if the address of the top left cell is smaller the split panes address, if freeze is applied

Definition at line 2530 of file Worksheet.cs.

◆ SetStyle() [1/4]

void NanoXLSX.Worksheet.SetStyle ( Address address,
Style style )

Sets the passed style on the passed (singular) cell address. If the cell is already existing, the style will be added or replaced. Otherwise, an empty cell will be added with the assigned style. If the passed style is null, all styles will be removed on existing cells and no additional (empty) cells are added to the worksheet.

Parameters
addressCell address to apply the style
styleStyle to apply or null to clear the range
Remarks
Note: This method may invalidate an existing date or time value since dates and times are defined by specific style. The result of a redefinition will be a number, instead of a date or time

Definition at line 1067 of file Worksheet.cs.

◆ SetStyle() [2/4]

void NanoXLSX.Worksheet.SetStyle ( Address startAddress,
Address endAddress,
Style style )

Sets the passed style on the passed cell range, derived from a start and end address. If cells are already existing, the style will be added or replaced. Otherwise, an empty cell will be added with the assigned style. If the passed style is null, all styles will be removed on existing cells and no additional (empty) cells are added to the worksheet.

Parameters
startAddressStart address of the cell range
endAddressEnd address of the cell range
styleStyle to apply or null to clear the range
Remarks
Note: This method may invalidate an existing date or time value since dates and times are defined by specific style. The result of a redefinition will be a number, instead of a date or time

Definition at line 1055 of file Worksheet.cs.

◆ SetStyle() [3/4]

void NanoXLSX.Worksheet.SetStyle ( Range cellRange,
Style style )

Sets the passed style on the passed cell range. If cells are already existing, the style will be added or replaced. Otherwise, an empty cell will be added with the assigned style. If the passed style is null, all styles will be removed on existing cells and no additional (empty) cells are added to the worksheet.

Parameters
cellRangeCell range to apply the style
styleStyle to apply
Remarks
Note: This method may invalidate an existing date or time value since dates and times are defined by specific style. The result of a redefinition will be a number, instead of a date or time

Definition at line 1020 of file Worksheet.cs.

◆ SetStyle() [4/4]

void NanoXLSX.Worksheet.SetStyle ( string addressExpression,
Style style )

Sets the passed style on the passed address expression. Such an expression may be a single cell or a cell range. If the cell is already existing, the style will be added or replaced. Otherwise, an empty cell will be added with the assigned style. If the passed style is null, all styles will be removed on existing cells and no additional (empty) cells are added to the worksheet.

Parameters
addressExpressionExpression of a cell address or range of addresses
styleStyle to apply or null to clear the range
Remarks
Note: This method may invalidate an existing date or time value since dates and times are defined by specific style. The result of a redefinition will be a number, instead of a date or time

Definition at line 1080 of file Worksheet.cs.

◆ SetVerticalSplit() [1/2]

void NanoXLSX.Worksheet.SetVerticalSplit ( float leftPaneWidth,
Address topLeftCell,
WorksheetPane? activePane )

Sets the vertical split of the worksheet into two panes. The measurement in characters cannot be used to freeze panes.

Parameters
leftPaneWidthWidth (similar to column width) from left of the worksheet to the split line in characters
topLeftCellTop Left cell address of the bottom right pane (if applicable). Only the column component is important in a vertical split
activePaneActive pane in the split window.
The parameter is nullable

Definition at line 2500 of file Worksheet.cs.

◆ SetVerticalSplit() [2/2]

void NanoXLSX.Worksheet.SetVerticalSplit ( int numberOfColumnsFromLeft,
bool freeze,
Address topLeftCell,
WorksheetPane? activePane )

Sets the vertical split of the worksheet into two panes. The measurement in columns can be used to split and freeze panes.

Parameters
numberOfColumnsFromLeftNumber of columns from left of the worksheet to the split line. The particular column widths are considered
freezeIf true, all panes are frozen, otherwise remains movable
topLeftCellTop Left cell address of the bottom right pane (if applicable). Only the column component is important in a vertical split
activePaneActive pane in the split window.
The parameter is nullable
Exceptions
WorksheetExceptionWorksheetException Thrown if the column number of the top left cell is smaller the split panes number of columns from left, if freeze is applied

Definition at line 2514 of file Worksheet.cs.

◆ SetZoomFactor()

void NanoXLSX.Worksheet.SetZoomFactor ( SheetViewType sheetViewType,
int zoomFactor )

Sets a zoom factor for a given SheetViewType. If AutoZoomFactor, the zoom factor is set to automatic.

Parameters
sheetViewTypeSheet view type to apply the zoom factor on
zoomFactorZoom factor in percent
Remarks
This factor is not the currently set factor. use the property ZoomFactor to set the factor for the current ViewType
Exceptions
WorksheetExceptionThrows a WorksheetException if the zoom factor is not AutoZoomFactor or below MinZoomFactor or above maxZoomFactor

Definition at line 2672 of file Worksheet.cs.

Member Data Documentation

◆ AutoZoomFactor

const int NanoXLSX.Worksheet.AutoZoomFactor = 0
static

Automatic zoom factor of a worksheet.

Definition at line 89 of file Worksheet.cs.

◆ DefaultWorksheetColumnWidth

readonly float NanoXLSX.Worksheet.DefaultWorksheetColumnWidth = 10f
static

Default column width as constant.

Definition at line 40 of file Worksheet.cs.

◆ DefaultWorksheetRowHeight

readonly float NanoXLSX.Worksheet.DefaultWorksheetRowHeight = 15f
static

Default row height as constant.

Definition at line 44 of file Worksheet.cs.

◆ MaxColumnNumber

readonly int NanoXLSX.Worksheet.MaxColumnNumber = 16383
static

Maximum column number (zero-based) as constant.

Definition at line 48 of file Worksheet.cs.

◆ MaxColumnWidth

readonly float NanoXLSX.Worksheet.MaxColumnWidth = 255f
static

Maximum column width as constant.

Definition at line 70 of file Worksheet.cs.

◆ MaxRowHeight

readonly float NanoXLSX.Worksheet.MaxRowHeight = 409.5f
static

Maximum row height as constant.

Definition at line 84 of file Worksheet.cs.

◆ MaxRowNumber

readonly int NanoXLSX.Worksheet.MaxRowNumber = 1048575
static

Maximum row number (zero-based) as constant.

Definition at line 74 of file Worksheet.cs.

◆ MaxWorksheetNameLength

readonly int NanoXLSX.Worksheet.MaxWorksheetNameLength = 31
static

Maximum number of characters a worksheet name can have.

Definition at line 36 of file Worksheet.cs.

◆ maxZoomFactor

const int NanoXLSX.Worksheet.maxZoomFactor = 400
static

Maximum zoom factor of a worksheet.

Definition at line 98 of file Worksheet.cs.

◆ MinColumnNumber

readonly int NanoXLSX.Worksheet.MinColumnNumber = 0
static

Minimum column number (zero-based) as constant.

Definition at line 53 of file Worksheet.cs.

◆ MinColumnWidth

readonly float NanoXLSX.Worksheet.MinColumnWidth = 0f
static

Minimum column width as constant.

Definition at line 59 of file Worksheet.cs.

◆ MinRowHeight

readonly float NanoXLSX.Worksheet.MinRowHeight = 0f
static

Minimum row height as constant.

Definition at line 65 of file Worksheet.cs.

◆ MinRowNumber

readonly int NanoXLSX.Worksheet.MinRowNumber = 0
static

Minimum row number (zero-based) as constant.

Definition at line 79 of file Worksheet.cs.

◆ MinZoomFactor

const int NanoXLSX.Worksheet.MinZoomFactor = 10
static

Minimum zoom factor of a worksheet. If set to this value, the zoom is set to automatic.

Definition at line 94 of file Worksheet.cs.

Property Documentation

◆ ActivePane

WorksheetPane? NanoXLSX.Worksheet.ActivePane
get

Gets the active Pane is splitting is applied.
The value is nullable. If null, no splitting was defined.

Definition at line 453 of file Worksheet.cs.

◆ ActiveStyle

Style NanoXLSX.Worksheet.ActiveStyle
get

Gets the active Style of the worksheet. If null, no style is defined as active.

Definition at line 461 of file Worksheet.cs.

◆ AutoFilterRange

Range? NanoXLSX.Worksheet.AutoFilterRange
get

Gets the range of the auto-filter. Wrapped to Nullable to provide null as value. If null, no auto-filter is applied.

Definition at line 216 of file Worksheet.cs.

◆ Cells

Dictionary<string, Cell> NanoXLSX.Worksheet.Cells
get

Gets the cells of the worksheet as dictionary with the cell address as key and the cell object as value.

Definition at line 224 of file Worksheet.cs.

◆ Columns

Dictionary<int, Column> NanoXLSX.Worksheet.Columns
get

Gets all columns with non-standard properties, like auto filter applied or a special width as dictionary with the zero-based column index as key and the column object as value.

Definition at line 232 of file Worksheet.cs.

◆ CurrentCellDirection

CellDirection NanoXLSX.Worksheet.CurrentCellDirection
getset

Gets or sets the direction when using AddNextCell method.

Definition at line 240 of file Worksheet.cs.

◆ DefaultColumnWidth

float NanoXLSX.Worksheet.DefaultColumnWidth
getset

Gets or sets the default column width.

Exceptions
RangeExceptionThrows a RangeException exception if the passed width is out of range (set)

Definition at line 246 of file Worksheet.cs.

◆ DefaultRowHeight

float NanoXLSX.Worksheet.DefaultRowHeight
getset

Gets or sets the default Row height.

Exceptions
RangeExceptionThrows a RangeException exception if the passed height is out of range (set)

Definition at line 263 of file Worksheet.cs.

◆ FreezeSplitPanes

bool? NanoXLSX.Worksheet.FreezeSplitPanes
get

Gets whether split panes are frozen.
The value is nullable. If null, no freezing is applied. This property also does not apply if PaneSplitAddress is null.

Definition at line 421 of file Worksheet.cs.

◆ Hidden

bool NanoXLSX.Worksheet.Hidden
getset

gets or sets whether the worksheet is hidden. If true, the worksheet is not listed in the worksheet tabs of the workbook.
If the worksheet is not part of a workbook, or the only one in the workbook, an exception will be thrown.
If the worksheet is the selected one, and attempted to set hidden, an exception will be thrown. Define another selected worksheet prior to this call, in this case.

Definition at line 378 of file Worksheet.cs.

◆ HiddenRows

Dictionary<int, bool> NanoXLSX.Worksheet.HiddenRows
get

Gets the hidden rows as dictionary with the zero-based row number as key and a boolean as value. True indicates hidden, false visible.

Remarks
Entries with the value false are not affecting the worksheet. These entries can be removed

Definition at line 280 of file Worksheet.cs.

◆ MergedCells

Dictionary<string, Range> NanoXLSX.Worksheet.MergedCells
get

Gets the merged cells (only references) as dictionary with the cell address as key and the range object as value.

Definition at line 296 of file Worksheet.cs.

◆ PaneSplitAddress

Address? NanoXLSX.Worksheet.PaneSplitAddress
get

Gets the split address for frozen panes or if pane split was defined in number of columns and / or rows.
For vertical splits, only the column component is considered. For horizontal splits, only the row component is considered.
The value is nullable. If null, no frozen panes or split by columns / rows are applied to the worksheet. However, splitting can still be applied, if the value is defined in characters.
See also: PaneSplitLeftWidth and PaneSplitTopHeight for splitting in characters (without freezing).

Definition at line 443 of file Worksheet.cs.

◆ PaneSplitLeftWidth

float? NanoXLSX.Worksheet.PaneSplitLeftWidth
get

Gets the width of the left, vertical split pane, measured from the left of the window.
The value is nullable. If null, no vertical split of the worksheet is applied
The value is only applicable to split the worksheet into panes, but not to freeze them.
See also: PaneSplitAddress.

Remarks
Note: This value will be modified to the Excel-internal representation, calculated by DataUtils.GetInternalColumnWidth(float, float, float).

Definition at line 412 of file Worksheet.cs.

◆ PaneSplitTopHeight

float? NanoXLSX.Worksheet.PaneSplitTopHeight
get

Gets the height of the upper, horizontal split pane, measured from the top of the window.
The value is nullable. If null, no horizontal split of the worksheet is applied.
The value is only applicable to split the worksheet into panes, but not to freeze them.
See also: PaneSplitAddress.

Remarks
Note: This value will be modified to the Excel-internal representation, calculated by DataUtils.GetInternalPaneSplitHeight(float).

Definition at line 399 of file Worksheet.cs.

◆ PaneSplitTopLeftCell

Address? NanoXLSX.Worksheet.PaneSplitTopLeftCell
get

Gets the Top Left cell address of the bottom right pane if applicable and splitting is applied.
The column is only relevant for vertical split, whereas the row component is only relevant for a horizontal split.
The value is nullable. If null, no splitting was defined.

Definition at line 431 of file Worksheet.cs.

◆ RowHeights

Dictionary<int, float> NanoXLSX.Worksheet.RowHeights
get

Gets defined row heights as dictionary with the zero-based row number as key and the height (float from 0 to 409.5) as value.

Definition at line 288 of file Worksheet.cs.

◆ SelectedCells

List<Range> NanoXLSX.Worksheet.SelectedCells
get

Gets the cell ranges of selected cells of this worksheet. Returns ans empty list if no cells are selected.

Definition at line 304 of file Worksheet.cs.

◆ SheetID

int NanoXLSX.Worksheet.SheetID
getset

Gets or sets the internal ID of the worksheet.

Definition at line 312 of file Worksheet.cs.

◆ SheetName

string NanoXLSX.Worksheet.SheetName
getset

Gets or sets the name of the worksheet.

Definition at line 328 of file Worksheet.cs.

◆ SheetProtectionPassword

virtual IPassword NanoXLSX.Worksheet.SheetProtectionPassword
getset

Password instance of the worksheet protection. If a password was set, the pain text representation and the hash can be read from the instance.

Remarks
The password of this property is stored in plain text at runtime but not stored to a worksheet. The plain text password cannot be recovered when loading a workbook. The hash is retrieved and can be reused

Definition at line 338 of file Worksheet.cs.

◆ SheetProtectionValues

List<SheetProtectionValue> NanoXLSX.Worksheet.SheetProtectionValues
get

Gets the list of SheetProtectionValues. These values define the allowed actions if the worksheet is protected.

Definition at line 347 of file Worksheet.cs.

◆ ShowGridLines

bool NanoXLSX.Worksheet.ShowGridLines
getset

Gets or sets whether grid lines are visible on the current worksheet. Default is true.

Definition at line 469 of file Worksheet.cs.

◆ ShowRowColumnHeaders

bool NanoXLSX.Worksheet.ShowRowColumnHeaders
getset

Gets or sets whether the column and row headers are visible on the current worksheet. Default is true.

Definition at line 474 of file Worksheet.cs.

◆ ShowRuler

bool NanoXLSX.Worksheet.ShowRuler
getset

Gets or sets whether a ruler is displayed over the column headers. This value only applies if ViewType is set to SheetViewType.PageLayout. Default is true.

Definition at line 479 of file Worksheet.cs.

◆ UseSheetProtection

bool NanoXLSX.Worksheet.UseSheetProtection
getset

Gets or sets whether the worksheet is protected. If true, protection is enabled.

Definition at line 355 of file Worksheet.cs.

◆ ViewType

SheetViewType NanoXLSX.Worksheet.ViewType
getset

Gets or sets how the current worksheet is displayed in the spreadsheet application (Excel).

Definition at line 484 of file Worksheet.cs.

◆ WorkbookReference

Workbook NanoXLSX.Worksheet.WorkbookReference
getset

Gets or sets the Reference to the parent Workbook.

Definition at line 360 of file Worksheet.cs.

◆ ZoomFactor

int NanoXLSX.Worksheet.ZoomFactor
getset

Gets or sets the zoom factor of the ViewType of the current worksheet. If AutoZoomFactor, the zoom factor is set to automatic.

Remarks
It is possible to add further zoom factors for inactive view types, using the function SetZoomFactor(SheetViewType, int)
Exceptions
WorksheetExceptionThrows a WorksheetException if the zoom factor is not AutoZoomFactor or below MinZoomFactor or above maxZoomFactor

Definition at line 502 of file Worksheet.cs.

◆ ZoomFactors

Dictionary<SheetViewType, int> NanoXLSX.Worksheet.ZoomFactors
get

Gets all defined zoom factors per SheetViewType of the current worksheet. Use SetZoomFactor(SheetViewType, int) to define the values.

Definition at line 517 of file Worksheet.cs.


The documentation for this class was generated from the following file: