[]
Represents a worksheet in a workbook.
IWorksheet provides access to worksheet content, ranges, views, events, and protection features, which can be used to read and modify cell data, manage worksheet state, and perform worksheet-related operations. This interface is typically obtained through ActiveSheet or Worksheets.
public interface IWorksheet
Public Interface IWorksheet
IWorksheet sheet = workbook.ActiveSheet;
IRange range = sheet.Range["A1:B2"];
range.Value = new object[,] {
{"Name", "Value"},
{"Test", 100}
};
| Name | Description |
|---|---|
| ActiveCell | Gets the active cell.
The active cell is returned as a single-cell IRange. Returns |
| ActivePane | Gets the active pane of the worksheet. Returns the IPane object that represents the pane currently active in the worksheet view. Use this property to access or modify the scroll position of the active pane after the worksheet has been split into multiple panes. |
| AutoFilter | Gets the IAutoFilter object for the worksheet.
The returned object provides access to the filter range, filters, and sort settings
for the worksheet's AutoFilter. Returns |
| AutoFilterMode | Gets or sets whether the AutoFilter drop-down arrows are currently displayed on the sheet. This property indicates whether the worksheet is showing the AutoFilter drop-down buttons for filtered ranges. |
| AutoGenerateColumns | Gets or sets whether columns are generated automatically when data is bound to the worksheet.
When this property is |
| AutoMergeRangesInfo | Gets a list of IAutoMergeRangeInfo objects that represent all auto merge range information in the current worksheet. Each item describes an auto-merge range that was added by AutoMerge(IRange, AutoMergeDirection, AutoMergeMode, AutoMergeSelectionMode). |
| BackgroundPicture | Gets or sets the background image data of the worksheet. Gets a byte array that contains the worksheet background image data, or an empty byte array if no background image is set. Set a byte array that contains the background image data, or null to remove the background image. |
| BackgroundPictures | Gets the collection of background pictures on the worksheet or chart sheet. The returned IBackgroundPictures object provides access to all IBackgroundPicture objects associated with the sheet. |
| CellType | Gets or sets the cell type for the worksheet. Use this property to retrieve the BaseCellType applied at the worksheet level. The returned cell type affects cells that inherit the worksheet's default cell type setting. |
| Cells | Gets the IRange object that represents all cells in the worksheet. The returned range covers the entire worksheet, including cells that are not currently in use. |
| ColumnCount | Gets or sets the current column count of the worksheet. This value represents the number of columns currently defined on the worksheet. It reflects the value set through ColumnCount. |
| Columns | Gets the IRange object that represents all the columns on the worksheet. The returned range can be used to access or manipulate columns by index. |
| Comments | Gets the IComments collection that represents all the comments in the worksheet. Use this property to access and enumerate cell comments in the current worksheet. |
| CommentsThreaded | Gets the ICommentsThreaded collection that represents all threaded comments in the worksheet. Each item in the returned collection is an ICommentThreaded object. Threaded comments are stored in the collection in row-major order. |
| Controls | Gets the control collection of this worksheet. |
| DataSource | Gets or sets the data source used for data binding in the current worksheet. This property returns the object previously assigned through DataSource. |
| FilterMode | Gets whether the worksheet is currently in filter mode. Filter mode indicates that a filter has been applied and the worksheet is actively filtering data. This differs from AutoFilterMode, which indicates whether AutoFilter is enabled on the worksheet. |
| FixedPageBreaks | Gets or sets whether the horizontal and vertical page breaks are fixed when rows or columns are inserted or deleted. When this property is |
| FreezeColumn | Gets the number of frozen columns in the worksheet.
This property returns the column position specified by FreezePanes(int, int).
Returns |
| FreezeRow | Gets the number of frozen rows in the worksheet.
This property returns the row position specified by FreezePanes(int, int).
Returns |
| FreezeTrailingColumn | Gets the number of trailing frozen columns in the worksheet.
This property returns the trailing frozen column position specified by FreezeTrailingPanes(int, int).
Returns |
| FreezeTrailingRow | Gets the number of trailing frozen rows in the worksheet.
This property returns the trailing frozen row position specified by FreezeTrailingPanes(int, int).
Returns |
| FrozenLineColor | Gets or sets the color of the frozen line.
This property returns the color used to display the divider between frozen and unfrozen panes.
If no frozen line color has been set, this property returns |
| HPageBreaks | Gets the collection of horizontal page breaks within the print area. Use the returned IHPageBreaks collection to access existing horizontal page breaks or add new ones within the worksheet print area. |
| Hyperlinks | Gets the collection of hyperlinks in the worksheet. Use this property to access, add, and manage worksheet-level hyperlinks through the returned IHyperlinks collection. |
| Index | Gets or sets the zero-based position of the worksheet in the workbook's worksheet collection. Getting the property returns the worksheet's current position. Setting the property moves the worksheet to the specified position. |
| Name | Gets or sets the name of the worksheet. This property returns the display name used to identify the worksheet in the workbook. |
| Names | Returns the INames collection that represents all worksheet-level names defined with the "WorksheetName!" prefix. This is a read-only Names object. |
| Outline | Gets the IOutline object that represents the outline for the worksheet. Use the returned outline object to access and configure worksheet outline settings for grouped rows and columns. |
| OutlineColumn | Gets the outline column for the worksheet. The outline column displays hierarchical row data in a tree view. Use the returned IOutlineColumn object to configure the column index and display options for the row hierarchy. |
| PageSetup | Gets the IPageSetup object for this worksheet. The returned object provides access to page setup settings such as print area, margins, orientation, scaling, and headers and footers. |
| Panes | Gets the panes in the worksheet. Returns the IPanes collection for the current worksheet view. Use this property to access the IPane objects in the worksheet, such as after calling SplitPanes(int, int). |
| PivotTables | Gets the collection of PivotTable reports on the worksheet. Use this property to access existing PivotTable reports on the worksheet or to add new ones through the returned IPivotTables collection. |
| Protection | Gets or sets the protection status of the worksheet. This property indicates whether worksheet protection is enabled. |
| ProtectionSettings | Gets the protection settings of the worksheet. Returns an IProtectionSettings object that provides access to the worksheet protection options. Changes to the returned settings take effect only when the worksheet is protected. |
| Range | Returns an instance of IRangeProvider which provides access to cell values, formulas, formatting and other cell properties and methods. |
| RowCount | Gets or sets the row count of the worksheet. This value represents the current number of rows available in the worksheet. |
| Rows | Gets an IRange object that represents all rows in the worksheet. You can use the returned range to access individual rows by index and perform row-level operations. |
| Scenarios | Gets the IScenarios object that represents the collection of What-If analysis scenarios in the worksheet. Use the returned collection to add, retrieve, and iterate worksheet scenarios. |
| Selection | Gets the current selection range on the worksheet.
Returns an IRange that represents the currently selected cells.
If the selection contains multiple areas, the returned range represents all selected areas.
Returns |
| Shapes | Gets the IShapes collection that contains all shapes on the worksheet or chart sheet. Use this property to access and manage drawing objects such as shapes, pictures, and charts associated with the current sheet. |
| SheetView | Gets the view settings of this worksheet. Use the returned IWorksheetView object to access worksheet display settings such as gridline visibility, reading direction, scroll position, zoom, and view type. |
| ShowColumnOutline | Gets or sets whether outline symbols for grouped columns are displayed. This setting applies to SpreadJS (SJS) serialization and viewing scenarios. |
| ShowRowOutline | Gets or sets whether outline symbols for grouped rows are displayed. This setting applies to SpreadJS (SJS) serialization and viewing scenarios. |
| Sort | Gets the sort settings for the current worksheet. Returns an ISort object that you can use to configure the sort range, sort fields, and sort orientation before calling Apply(). |
| SplitColumn | Gets the split column position of the worksheet.
This property returns the column position specified by SplitPanes(int, int).
Returns |
| SplitRow | Gets the split row position of the worksheet.
This property returns the row position specified by SplitPanes(int, int).
Returns |
| StandardHeight | Gets or sets the default row height for the worksheet, in points. To use a pixel value, use StandardHeightInPixel. |
| StandardHeightInPixel | Gets or sets the default row height for the worksheet, in pixels. To use a value in points, use StandardHeight. |
| StandardWidth | Gets or sets the standard width, in points, for columns in the worksheet. This value represents the worksheet's default column width setting. |
| StandardWidthInPixel | Gets or sets the standard width, in pixels, for columns in the worksheet. This value represents the worksheet's default column width setting in pixel units. |
| TabColor | Gets or sets the primary color of the worksheet tab. Use this property to retrieve the color currently applied to the tab. To change the tab color, use TabColor. |
| Tables | Gets the collection of ITable objects in the worksheet. Use the returned ITables collection to create, access, and manage tables defined on the current worksheet. The collection can be empty if the worksheet does not contain any tables. |
| Tag | Gets or sets the custom tag associated with the worksheet. Use this property to retrieve application-defined metadata stored with the worksheet. To assign a tag, use Tag. |
| Type | Gets the sheet type. Use this property to determine whether the current sheet is a regular worksheet or another supported sheet type, such as a chart sheet. |
| UsedRange | Returns the IRange object that represents the used range on the specified worksheet, its behavior is equivalent to GetUsedRange(UsedRangeType.Axis | UsedRangeType.Data | UsedRangeType.Comment | UsedRangeType.Style | UsedRangeType.Merge). |
| VPageBreaks | Gets the collection of vertical page breaks within the print area. Use the returned IVPageBreaks collection to add, access, and manage vertical page breaks on the worksheet. |
| Visible | Gets or sets the visibility state of the worksheet. The returned value indicates whether the worksheet is currently shown, hidden, or very hidden. |
| Workbook | Gets the Workbook that contains this worksheet. Use this property to access workbook-level settings, collections, and operations from the current worksheet. |
| Name | Description |
|---|---|
| Activate() | Makes this worksheet the active sheet. This method is equivalent to clicking the worksheet tab in the workbook UI. |
| AutoMerge(IRange, AutoMergeDirection, AutoMergeMode, AutoMergeSelectionMode) | Applies auto merge to the specified range by using the specified or default direction, mode, and selection mode. This method adds auto-merge information to the specified range so that adjacent cells with the same value can be merged automatically. If |
| Copy(IWorkbook) | Copies the sheet to the end of the specified workbook. The copied sheet is appended to the destination workbook and returned as a new worksheet instance. If |
| CopyAfter(IWorksheet) | Copies the sheet to the location after the specified sheet. The copied sheet is inserted immediately after |
| CopyBefore(IWorksheet) | Copies the sheet to the location before the specified sheet. The copied sheet is inserted immediately before |
| Delete() | Deletes this worksheet from its workbook. If this worksheet is the active worksheet, another worksheet may become active after the deletion. |
| Evaluate(string) | Evaluates the specified Excel formula or named expression and returns the result. The formula is evaluated by using non-dynamic array semantics. |
| Evaluate(string, IFormulaResolver) | Evaluates the specified Excel formula or named expression by using a custom formula resolver and returns the result. Use the resolver to supply values for custom names referenced by the formula. The calculation behavior is consistent with Excel 2019 and earlier versions. |
| Evaluate2(string) | Evaluates the specified Excel formula or named expression and returns the result. The formula is evaluated by using dynamic array semantics. |
| FreezePanes(int, int) | Freezes panes at the specified row and column positions. Use this method to keep the rows above the specified row position and the columns to the left of the specified column position visible while scrolling the worksheet. |
| FreezeTrailingPanes(int, int) | Sets trailing frozen panes at the specified row and column positions. This method sets the number of trailing rows and trailing columns that remain visible when the worksheet is scrolled. |
| FromJson(Stream, DeserializationOptions) | Generates a worksheet from the JSON stream. |
| FromJson(string, DeserializationOptions) | Generates a worksheet from the specified JSON string using the provided deserialization options. Use DeserializationOptions to control how the JSON data is loaded, such as whether formulas or styles are ignored and whether recalculation is prevented after loading. |
| GetUsedRange(UsedRangeType) | Gets the used range. |
| Move(IWorkbook) | Moves the worksheet to the end of the specified workbook, or to the end of the current workbook when no workbook is specified. If |
| MoveAfter(IWorksheet) | Moves the sheet to the location after the specified sheet. The target sheet can belong to the same workbook or another workbook. |
| MoveBefore(IWorksheet) | Moves the sheet to the location before the specified sheet. The target sheet can belong to the same workbook or a different workbook. |
| PrintOut(PrintOutOptions) | Prints the worksheet. |
| Protect(string) | Protects a worksheet so that it cannot be modified. Use this method to apply worksheet protection without passing a password. To remove the protection later, use Unprotect(string). |
| Save(Stream, SaveFileFormat) | Saves current worksheet to the specified format file stream. |
| Save(Stream, SaveOptionsBase) | Saves current worksheet to the specified file stream. |
| Save(string) | Saves the current worksheet to the specified file. The output format is inferred from the file name extension. |
| Save(string, SaveFileFormat) | Saves current worksheet to the specified format file. |
| Save(string, SaveOptionsBase) | Saves current worksheet to the specified file. |
| Select(bool) | Selects the worksheet.
If |
| ShowAllData() | Makes all rows in the currently filtered range visible. If AutoFilter is in use on the worksheet, this method clears the applied filter criteria and changes the filter drop-down arrows to show All. |
| SplitPanes(int, int) | Splits the worksheet into panes at the specified row and column positions. Use this method to divide the worksheet view into multiple panes so that different areas of the worksheet can be viewed independently. |
| ToImage(Stream, ImageType) | Saves the worksheet to the specified image stream. |
| ToImage(Stream, ImageType, ImageSaveOptions) | Saves the worksheet to the specified image stream using options. |
| ToImage(string) | Saves the worksheet to the specified image file. Use this method to export the current worksheet as an image. |
| ToImage(string, ImageSaveOptions) | Saves the worksheet to the specified image file using options. |
| ToJson(SerializationOptions) | Generates a JSON string from the worksheet.
Serializes the current worksheet to JSON and applies the specified
SerializationOptions during serialization. If
|
| ToJson(Stream, SerializationOptions) | Generates a JSON stream from a worksheet. |
| UnfreezePanes() | Unfreezes panes. This method clears the pane freeze state that was applied by FreezePanes(int, int). |
| UnfreezeTrailingPanes() | Removes trailing frozen panes. This method clears the trailing frozen pane state that was applied by FreezeTrailingPanes(int, int). |
| Unprotect(string) | Removes worksheet protection by using the specified password. Pass null only when the worksheet was protected without a password. |
| UnsplitPanes() | Removes pane splits from the worksheet.
This method clears the current split pane layout and restores the worksheet
to a single-pane view. The implementation forwards to SplitPanes(int, int)
with both arguments set to |
| Name | Description |
|---|---|
| Activated | Occurs when the worksheet is activated. |
| BeforeDelete | Occurs before the worksheet is deleted. |
| Changed | Occurs when something changes in the cells. |
| Deactivated | Occurs when the worksheet is deactivated. |
| SelectionChange | Occurs when the selection changes on a worksheet. |