Worksheet
- interface ClosedXML.Excel.IXLWorksheet : IXLRangeBase, IXLProtectable<IXLSheetProtection, XLSheetProtectionElements>
Subclassed by XLWorksheet
Public Functions
- IXLRow? FirstRowUsed ()
Gets the first non-empty row of the worksheet that contains a cell with a value.
Formatted empty cells do not count.
- IXLRow? FirstRowUsed (XLCellsUsedOptions options)
Gets the first non-empty row of the worksheet that contains a cell with a value.
- Param options
The options to determine whether a cell is used.
- IXLRow? LastRowUsed ()
Gets the last non-empty row of the worksheet that contains a cell with a value.
- IXLRow? LastRowUsed (XLCellsUsedOptions options)
Gets the last non-empty row of the worksheet that contains a cell with a value.
- Param options
The options to determine whether a cell is used.
- IXLColumn? FirstColumnUsed ()
Gets the first non-empty column of the worksheet that contains a cell with a value.
- IXLColumn? FirstColumnUsed (XLCellsUsedOptions options)
Gets the first non-empty column of the worksheet that contains a cell with a value.
- Param options
The options to determine whether a cell is used.
- IXLColumn? LastColumnUsed ()
Gets the last non-empty column of the worksheet that contains a cell with a value.
- IXLColumn? LastColumnUsed (XLCellsUsedOptions options)
Gets the last non-empty column of the worksheet that contains a cell with a value.
- Param options
The options to determine whether a cell is used.
- IXLColumns Columns ()
Gets a collection of all columns in this worksheet.
- IXLColumns Columns (String columns)
Gets a collection of the specified columns in this worksheet, separated by commas.
e.g. Columns(“G:H”), Columns(“10:11,13:14”), Columns(“P:Q,S:T”), Columns(“V”)
- Param columns
The columns to return.
- IXLColumns Columns (String firstColumn, String lastColumn)
Gets a collection of the specified columns in this worksheet.
- Param firstColumn
The first column to return.
- Param lastColumn
The last column to return.
- IXLColumns Columns (Int32 firstColumn, Int32 lastColumn)
Gets a collection of the specified columns in this worksheet.
- Param firstColumn
The first column to return.
- Param lastColumn
The last column to return.
- IXLRows Rows (String rows)
Gets a collection of the specified rows in this worksheet, separated by commas.
e.g. Rows(“4:5”), Rows(“7:8,10:11”), Rows(“13”)
- Param rows
The rows to return.
- IXLRows Rows (Int32 firstRow, Int32 lastRow)
Gets a collection of the specified rows in this worksheet.
- Param firstRow
The first row to return.
- Param lastRow
The last row to return.
- IXLColumn Column (Int32 column)
Gets the specified column of the worksheet.
- Param column
The worksheet’s column.
- IXLColumn Column (String column)
Gets the specified column of the worksheet.
- Param column
The worksheet’s column.
- IXLCell Cell (int row, int column)
Gets the cell at the specified row and column.
- Param row
The cell’s row.
- Param column
The cell’s column.
- IXLCell Cell (string cellAddressInRange)
Gets the cell at the specified address.
- Param cellAddressInRange
The cell address in the worksheet.
- Throws ArgumentException
Address is not A1 or workbook-scoped named range.
- IXLCell Cell (int row, string column)
Gets the cell at the specified row and column.
- Param row
The cell’s row.
- Param column
The cell’s column.
- IXLCell Cell (IXLAddress cellAddressInRange)
Gets the cell at the specified address.
- Param cellAddressInRange
The cell address in the worksheet.
- IXLRange Range (IXLRangeAddress rangeAddress)
Returns the specified range.
- Param rangeAddress
The range boundaries.
- IXLRange Range (string rangeAddress)
Returns the specified range.
e.g. Range(“A1”), Range(“A1:C2”)
- Param rangeAddress
The range boundaries.
- Throws ArgumentException
rangeAddress is not a valid address or named range.
- IXLRange Range (IXLCell firstCell, IXLCell lastCell)
Returns the specified range.
- Param firstCell
The first cell in the range.
- Param lastCell
The last cell in the range.
- IXLRange Range (string firstCellAddress, string lastCellAddress)
Returns the specified range.
- Param firstCellAddress
The first cell address in the worksheet.
- Param lastCellAddress
The last cell address in the worksheet.
- IXLRange Range (IXLAddress firstCellAddress, IXLAddress lastCellAddress)
Returns the specified range.
- Param firstCellAddress
The first cell address in the worksheet.
- Param lastCellAddress
The last cell address in the worksheet.
- IXLRanges Ranges (string ranges)
Returns a collection of ranges, separated by commas.
e.g. Ranges(“A1”), Ranges(“A1:C2”), Ranges(“A1:B2,D1:D4”)
- Param ranges
The ranges to return.
- IXLRange Range (int firstCellRow, int firstCellColumn, int lastCellRow, int lastCellColumn)
Returns the specified range.
- Param firstCellRow
The first cell’s row of the range to return.
- Param firstCellColumn
The first cell’s column of the range to return.
- Param lastCellRow
The last cell’s row of the range to return.
- Param lastCellColumn
The last cell’s column of the range to return.
- Return
.
- int RowCount ()
Gets the number of rows in this worksheet.
- int ColumnCount ()
Gets the number of columns in this worksheet.
- IXLWorksheet CollapseRows ()
Collapses all outlined rows.
- IXLWorksheet CollapseColumns ()
Collapses all outlined columns.
- IXLWorksheet ExpandRows ()
Expands all outlined rows.
- IXLWorksheet ExpandColumns ()
Expands all outlined columns.
- IXLWorksheet CollapseRows (Int32 outlineLevel)
Collapses the outlined rows of the specified level.
- Param outlineLevel
The outline level.
- IXLWorksheet CollapseColumns (Int32 outlineLevel)
Collapses the outlined columns of the specified level.
- Param outlineLevel
The outline level.
- IXLWorksheet ExpandRows (Int32 outlineLevel)
Expands the outlined rows of the specified level.
- Param outlineLevel
The outline level.
- IXLWorksheet ExpandColumns (Int32 outlineLevel)
Expands the outlined columns of the specified level.
- Param outlineLevel
The outline level.
- void Delete ()
Deletes this worksheet.
- IXLNamedRange NamedRange (String rangeName)
Gets the specified named range.
- Param rangeName
Name of the range.
- Throws ArgumentException
Range wasn’t found in sheet named ranges.
- IXLTable Table (Int32 index)
Gets the Excel table of the given index
- Param index
Index of the table to return
- IXLTable Table (String name)
Gets the Excel table of the given name
- Param name
Name of the table to return
- IXLWorksheet CopyTo (String newSheetName)
Copies the
- Param newSheetName
- IXLWorksheet CopyTo (XLWorkbook workbook, String newSheetName)
Copy a worksheet from this workbook to a different workbook as a new sheet.
- Param workbook
Workbook into which copy this sheet.
- Param newSheetName
Name of new sheet in the workbook where will the data be copied. Sheet will be in the last position.
- Return
Newly created sheet in the workbook .
- XLCellValue Evaluate (String expression, string? formulaAddress = null)
Evaluate an formula and return a result.
- Param expression
Formula to evaluate.
- Param formulaAddress
A cell address that is used to provide context for formula calculation (mostly implicit intersection).
- Throws MissingContextException
If formulaAddress was needed for some part of calculation.
- void RecalculateAllFormulas ()
Force recalculation of all cell formulas in the sheet while leaving other sheets without change, even if their dirty cells.
Properties
- XLWorkbook Workbook { get; set; }
Gets the workbook that contains this worksheet
- Double ColumnWidth { get; set; }
Gets or sets the default column width for this worksheet.
- Double RowHeight { get; set; }
Gets or sets the default row height for this worksheet.
- String Name { get; set; }
Gets or sets the name (caption) of this worksheet.
- Int32 Position { get; set; }
Gets or sets the position of the sheet.
When setting the Position all other sheets’ positions are shifted accordingly.
- IXLPageSetup PageSetup { get; set; }
Gets an object to manipulate the sheet’s print options.
- IXLOutline Outline { get; set; }
Gets an object to manipulate the Outline levels.
- IXLNamedRanges NamedRanges { get; set; }
Gets an object to manage this worksheet’s named ranges.
- IXLSheetView SheetView { get; set; }
Gets an object to manage how the worksheet is going to displayed by Excel.