Click or drag to resize

WorkSheet Class

Class that stands for single sheet within Excel file.
Inheritance Hierarchy

Namespace:  IronXL
Assembly:  IronXL (in IronXL.dll) Version: 2019.3.2
Syntax
public class WorkSheet : Range

The WorkSheet type exposes the following members.

Properties
  NameDescription
Public propertyBoolValue
Gets or sets the Boolean value of this Range of cells.

Getting the BoolValue will return true only if ALL cells in the range are true. Numeric cells greater than zero are treated as TRUE. [Logical AND Operator Applied]

Setting the BoolValue will set all cells in with the same Boolean value.

(Inherited from Range.)
Public propertyColumns
List of Excel columns within the current range. The Columns contains Cell objects.
(Inherited from Range.)
Public propertyDateTimeValue
Gets or sets the nullable DateTime value of this Range of cells.

Getting the DateTimeValue will return highest (MAX) DateTime in the Range, or null if no DateTime is found.

Setting the DateTimeValue will set all cells in with the same DateTime value.

(Inherited from Range.)
Public propertyDecimalValue
Gets or sets the Decimal value of this Range of cells.

Getting the DecimalValue will return the SUM of all numeric cells in the Range.

Setting the DecimalValue will set all cells in with the same Decimal value.

(Inherited from Range.)
Public propertyDisplayGridlines
Gets or sets a value indicating whether to display grid-lines.
Public propertyDoubleValue
Gets or sets the double value of all Cells in this Rance.
(Inherited from Range.)
Public propertyFitToPage
Flag indicating whether the Fit to Page print option is enabled.
Public propertyFloatValue
Gets or sets the Single value of this Range of cells.

Getting the FloatValue will return the SUM of all numeric cells in the Range.

Setting the FloatValue will set all cells in with the same Single value.

(Inherited from Range.)
Public propertyFooter
Gets the print footer of the worksheet.
Public propertyHeader
Gets the print header of the worksheet.
Public propertyHorizontallyCenter
Determine whether printed output for this sheet will be horizontally centered.
Public propertyImages
A list of images contained within the sheet.
Public propertyInt32Value

Synonym of IntValue

Gets or sets the Int32 (Int32) value of this Range of cells.

Getting the LongValue will return the SUM of all numeric cells in the Range.

Setting the LongValue will set all cells in with the same Int32 value.

(Inherited from Range.)
Public propertyInt64Value

Synonym of LongValue

Gets or sets the Int64 (Int64) value of this Range of cells.

Getting the LongValue will return the SUM of all numeric cells in the Range.

Setting the LongValue will set all cells in with the same Int64 value.

(Inherited from Range.)
Public propertyIntValue
Gets or sets the Int32 value of this Range of cells.

Getting the IntValue will return the SUM of all numeric cells in the Range.

Setting the IntValue will set all cells in with the same Int32 value.

(Inherited from Range.)
Public propertyIsEmpty
Property that indicates if range is empty.
(Inherited from Range.)
Public propertyIsPrintGridlines
Gets or sets a value indicating whether to display grid-lines when printing.
Public propertyItem
Indexer for getting range with specified range address. Range MyRange = workSheet["A12:B18"]
Public propertyLongValue
Gets or sets the Int64 (Int64) value of this Range of cells.

Getting the LongValue will return the SUM of all numeric cells in the Range.

Setting the LongValue will set all cells in with the same Int64 value.

(Inherited from Range.)
Public propertyName
Worksheet name
Public propertyPrintSetup
Gets the print setup object.
Public propertyRangeAddressAsString
Gets a string representation of this range address.

E.g. "A1:B25"

(Inherited from Range.)
Public propertyRows
List of Excel rows within the current range. The Rows contains Cell objects.
(Inherited from Range.)
Public propertyStringValue
Gets or sets the String value of this Range of cells.

Getting the StringValue will return formated String values. Columns will be delimited by TABS. Rows delimited by NEWLINE

Setting the StringValue will set all cells in with the same String value.

(Inherited from Range.)
Public propertyStyle
Style of all cells within range.
(Inherited from Range.)
Public propertyValue
Property to get or set range value.

If range contains one cell: {get} returns the cell value, {set} changes the cell value

If range contains more than one cell: {get} returns the sum of all numeric cells within range, {set} changes the value of every cell within the range.

(Inherited from Range.)
Public propertyVerticallyCenter
Determine whether printed output for this sheet will be vertically centered.
Public propertyWorkBook
The workbook this range belongs to.
(Inherited from Range.)
Top
Methods
  NameDescription
Public methodAddRange
Add another range to this current range. Basically, the result is union of two ranges.
(Inherited from Range.)
Public methodAvg
Returns average value of all numeric cells
(Inherited from Range.)
Public methodCopy
Copies the specified range to the sheet and inserts it at the specified point.

E.g. Pastes this range to a WorkSheet at a specified cell location

(Inherited from Range.)
Public methodCopySheet
Duplicates this WorkSheet within the same excel WorkBook.
Public methodCopyTo
Copies worksheet to another workbook with the specified name.
Public methodCreateFreezePane(Int32, Int32)
Creates a freeze pane. Any existing freeze pane or split pane is overwritten.
Public methodCreateFreezePane(Int32, Int32, Int32, Int32)
Creates a freeze pane. Any existing freeze pane or split pane is overwritten.
Public methodCreateSplitPane
Creates a split pane. Any existing freeze pane or split pane is overwritten.
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Public methodGetEnumerator
IEnumerable implementation.
(Inherited from Range.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetRange
Get range with specified range address

E.g. Range myRange = mySheet.GetRange("A1:C62")

Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodGetValueTType
Method for getting a range's value.

If range contains one cell then method calls GetValueTType of this cell

If range contains more than one cell then method tries to cast Sum of all numeric cells within range to TType

Use Try/Catch to avoid possible exceptions from this method if cell content types are inconsistent or contain formula errors.

(Inherited from Range.)
Public methodInsertImage
Inserts image from the specified path to the worksheet. The size of the picture is defined by col/row coordinates.
Public methodMax
Returns maximum value of all numeric cells
(Inherited from Range.)
Public methodMerge
Merges the specified range into a single cell.
Public methodMin
Returns minimum value of all numeric cells within this range.
(Inherited from Range.)
Public methodRemoveImage
Removes the image by its id. Id can be retrieved from the IImage object
Public methodRemovePane
Removes the freeze or the split pane.
Public methodReplace

Textual and numeric Find and Replace.

Replaces all found occurrences of "oldValue" with the "newValue". Works with all string and numeric values.
(Inherited from Range.)
Public methodSaveAs
Exports the worksheet with as a new worksheet to: CSV, TSV, JSON, Excel or XML
Public methodSaveAsCsv
Saves the worksheet into a new CSV file.
Public methodSaveAsJson
Saves the worksheet into a new JSON file.
Public methodSaveAsNewExcelFile
Saves the worksheet into a new excel file on disk.
Public methodSaveAsXml
Saves the worksheet into a new XML file.
Public methodSetCellValue
Set a single cell value using its row and column indexes.
(Inherited from Range.)
Public methodSetPrintArea
Sets the print area for this worksheet.

E.g. "A1:X82"

Public methodSetZoom
Sets the zoom scale for this worksheet.

100 is normal zoom.

Public methodSortAscending
Sort current range in ascending order. This updates the cell positions within your WorkSheets.
(Inherited from Range.)
Public methodSortDescending
Sort current range in descending order. This updates the cell positions within your WorkSheets.
(Inherited from Range.)
Public methodSubtractRange
Subtracts a range from the current. Result is first range without intersection of two ranges.
(Inherited from Range.)
Public methodSum
Returns sum of all numeric cells .
(Inherited from Range.)
Public methodToArray
Converts the worksheet to flattened array of cells.
Public methodToDataTable
Get DataTable representation of current range.

Useful when working with DataGrids or System.Data or Entity Framework

(Inherited from Range.)
Public methodToMultiDimensionalArray
Convert worksheet to two-dimensional array of cells
Public methodToString
Returns the StringValue of this Range.
(Inherited from Range.)
Public methodTrim
Removes all empty rows and columns on the range borders.
(Inherited from Range.)
Public methodTryGetValueTType
Method for safely getting a range's total value.

If range contains one cell then method calls GetValueTType of this cell

If range contains more than one cell then method tries to cast Sum of all numeric cells within range to TType

Use Try/Catch to avoid possible exceptions from this method if cell content types are inconsistent or contain formula errors.

(Inherited from Range.)
Public methodUnmerge(Int32)
Un-Merges the specified merge region by index.

To learn about indexes, see Merge(String).

Public methodUnmerge(String)
Un-Merges a specified range of cells.
Top
See Also