Description
TheWorksheet
class represents a single Excel worksheet.
Remarks
To add a Worksheet to a Workbook, call Workbook.Worksheets.CreateWorksheet(). To get an existing Worksheet call Workbook.Worksheets[index or name].Examples
Properties
Name | Description |
---|---|
Returns a Cells collection that contains all cells in the worksheet. | |
Returns a Charts collection containing all the charts contained as objects within this worksheet. Use this collection to add, access, and remove charts from the worksheet. | |
Returns a Comments collection that contains all comments in the worksheet. | |
Sets or returns the 0-based index of the first column that is shown in the worksheet. | |
Sets or returns the 0-based index of the first row that is shown in the worksheet. | |
Freezes panes in a worksheet or returns the cell at which the panes are split. Set the property to a Cell object. The cell specified in Worksheet.FreezePanes is the first unfrozen cell; freeze panes will be applied to all rows above the cell and all columns to the left of the cell. | |
Sets or returns a Color object representing the color of the gridlines in the worksheet. | |
Returns the collection of hyperlinks in the worksheet. | |
Returns whether or not the worksheet is write-protected. | |
Returns whether this worksheet is selected. | |
Sets or returns the name of the worksheet. Sheet names are limited to 255 characters and must not contain the following characters: \ / ? [ ] : ' | |
Returns the named ranges of the Worksheet as an array of NamedObject objects as an IEnumerable collection. Though the named ranges are not returned in any particular order, they iterable. | |
Returns a PageSetup object representing page layout properties of a printed worksheet. | |
Returns a Pictures collection containing all pictures in the worksheet. Use this collection to add, access, and remove pictures from the worksheet. | |
Returns a rectanglular area of cells from the first (top, left) populated cell to the last (bottom, right) populated cell in the worksheet. The area returned will include cells that contain no data but have been formatted. | |
Returns the 0-based index of the worksheet in the collection of all sheets in the workbook. | |
Sets or returns the password hash that is used to write-protect (not encrypt) the worksheet. | |
Returns a Groups collection containing all shape groups within the worksheet. | |
Returns a Shapes collection containing all shapes within the worksheet. | |
Returns a SheetProtection object containing all protection properties on the worksheet. | |
Sets or returns whether formulas or their calculated values will be displayed in the worksheet. Calculated values are displayed by default. | |
Sets or returns whether gridlines should be shown in the worksheet. Gridlines are shown by default. | |
Sets or returns whether column and row headers will be displayed in the worksheet. The headers are displayed by default. | |
Sets or returns whether zero values in cells will be displayed in the worksheet. Zero values are displayed by default. | |
Sets or returns the default row height in points (1/72 of an inch). This must be between 0 and 409. | |
Sets or returns the default column width, in points (1/72 of an inch). | |
Sets or returns the default column width as a number of character widths in the 'Normal' font. This must be a value between 0 and 255. | |
When grouping columns, SummaryColumns determines where the summary columns for the groups are located. By default the summary rows are located to the right of the groupings. | |
When grouping rows, SummaryRows determines where the summary rows for the groups are located. By default the summary rows are located below the groupings. | |
Sets or returns the color of the worksheet's sheet name tab. Setting the color to an automatic color will set the color to no color. | |
Returns the Workbook object in which this worksheet resides. | |
Sets or returns the worksheet's viewing mode. | |
Sets or returns the visibility setting of the worksheet. | |
Sets or returns the percentage of standard size by which the worksheet will be magnified or reduced. Set this property to a value between 10 and 400. |
Indexers
Name | Description |
---|---|
Returns the cell at a specified row and column position. This property is an indexer for the Worksheet class. | |
Returns the cell at the specified Excel-style reference. This property is an indexer for the Worksheet class. |
Methods
Name | Description |
---|---|
Copies an area of cells from another Worksheet to cells in this worksheet. | |
Copies an area of cells from another Worksheet to cells in this worksheet. | |
Copies an area of cells from another Worksheet to cells in this worksheet. | |
Copies an area of cells from a Worksheet in either the same workbook or another workbook. | |
Copies an area of cells from another Worksheet to cells in this worksheet. | |
Copies an area of cells from another Worksheet to cells in this worksheet. | |
Creates an anchor at a specified position in the worksheet. | |
Defines a rectangular Area of cells in the worksheet. | |
Defines a rectangular Area of cells in the worksheet. | |
Returns an Area object representing all the cells in a specified group of columns. An area is a rectangular collection of cells. | |
Returns an Area object representing all the cells in a specified group of rows. An area is a rectangular collection of cells. | |
Creates a named range, containing one area. A range is a collection of areas; an area is a rectangular collection of cells. | |
Creates a named range from a specified formula. A range is a collection of areas; an area is a rectangular collection of cells. This method can be used to create a non-rectangular range containing multiple rectangular areas. | |
Creates a range from a specified formula. A range is a collection of areas; an area is a rectangular collection of cells. This method can be used to create a non-rectangular range containing multiple rectangular areas. | |
Deletes a column and its contents from the worksheet. Columns after the deleted column will be moved to the left. | |
Deletes a number of columns and its contents from the worksheet. Columns after the deleted columns will be moved to the left. | |
Deletes a specified row and its contents from the worksheet. Rows below the deleted row will be moved up. | |
Deletes a specified number of rows and its contents from the worksheet. Rows below the deleted rows will be moved up. | |
Returns a ColumnProperties object representing the column specified by index. | |
Returns the NamedObject object that represents the name of a specified array, number, picture, or range. If the named object does not exist, the method returns null. | |
Returns the named Range object that specified by name. If the named range does not exist, the method returns null. | |
Returns a RowProperties object representing the row specified by index. | |
Groups or outlines a contiguous set of columns. | |
Groups or outlines a contiguous set of rows. | |
Imports data from a two-dimensional array of objects to cells in the worksheet. | |
ImportData(Object()(), String(), Cell, DataImportProperties) | Imports data from a two-dimensional array of objects to cells in the worksheet. The new data will overwrite values and formulas in the target worksheet cells, but existing formatting will be preserved. |
Imports data from an ADO.NET DataTable to cells in the worksheet. The new data will overwrite values and formulas in the target worksheet cells, but existing formatting will be preserved. | |
ImportData(System.Data.DataTable, Cell, DataImportProperties) | Imports data from an ADO.NET DataTable to cells in the worksheet. The new data will overwrite values and formulas in the target worksheet cells, but existing formatting will be preserved. |
Imports data from an ADO.NET DataView to cells in the worksheet. The new data will overwrite values and formulas in the target worksheet cells, but existing formatting will be preserved. | |
ImportData(System.Data.DataView, Cell, DataImportProperties) | Imports data from an ADO.NET DataView to cells in the worksheet. The new data will overwrite values and formulas in the target worksheet cells, but existing formatting will be preserved. |
Imports data from a rectangular array of objects to cells in the worksheet. The new data will overwrite values and formulas in the target worksheet cells, but existing formatting will be preserved. | |
Imports data from a rectangular array of objects to cells in the worksheet. The new data will overwrite values and formulas in the target worksheet cells, but existing formatting will be preserved. | |
Imports data from an IDataReader to cells in the worksheet. The new data will overwrite values and formulas in the target worksheet cells, but existing formatting will be preserved. | |
ImportData(System.Data.IDataReader, Cell, DataImportProperties) | Imports data from an IDataReader to cells in the worksheet. The new data will overwrite values and formulas in the target worksheet cells, but existing formatting will be preserved. |
Inserts a column in the worksheet to the left of the specified column. | |
Inserts a column in the worksheet to the left of the specified column, copying the style based on the copyBehavior parameter. | |
InsertColumn(Int32, ColumnInsertBehavior, ColumnInsertBehavior) | Inserts a column in the worksheet to the left of the specified column, copying the style based on the copyBehavior parameter. |
Inserts a block of columns in the worksheet to the left of the specified column. | |
Inserts a block of columns in the worksheet to the left of the specified column, copying the style based on the copyBehavior parameter. | |
InsertColumns(Int32, Int32, ColumnInsertBehavior, ColumnInsertBehavior) | Inserts a block of columns in the worksheet to the left of the specified column, copying the style based on the copyBehavior parameter. |
Inserts a horizontal page break in the worksheet after the specified cell. | |
Inserts a row in the worksheet above the specified row. | |
Inserts a row in the worksheet above the specified row. | |
Inserts a row in the worksheet above the specified row. | |
Inserts a number of rows in the worksheet above the specified row. | |
Inserts a number of rows in the worksheet above the specified row. | |
InsertRows(Int32, Int32, RowInsertBehavior, RowInsertBehavior) | Inserts a number of rows in the worksheet above the specified row. |
Inserts a vertical page break in the worksheet to right of the specified cell. | |
Write-protects the worksheet. A user will not be able to modify the worksheet in Excel without entering the specified password. This method does not encrypt the worksheet. | |
Selects the current worksheet and deselects all others. To select multiple worksheets, use Worksheets.Select(). | |
Ungroups a contiguous set of columns. | |
Ungroups a contiguous set of rows. | |
Removes the write-protection from the worksheet. |
Extension Methods
Overload | Description |
---|---|
ImportData(Cell, Microsoft.SharePoint.SPList, DataImportProperties) | Imports data from a SharePoint List to cells in the worksheet. The new data will overwrite values and formulas in the target worksheet cells, but existing formatting will be preserved. |
Imports data from a SharePoint List to cells in the worksheet. The new data will overwrite values and formulas in the target worksheet cells, but existing formatting will be preserved. | |
ImportData(Cell, Microsoft.SharePoint.SPView, Microsoft.SharePoint.SPList, DataImportProperties) | Imports data from a SharePoint View to cells in the worksheet. The new data will overwrite values and formulas in the target worksheet cells, but existing formatting will be preserved. |
ImportData(Cell, Microsoft.SharePoint.SPView, Microsoft.SharePoint.SPList) | Imports data from a SharePoint View to cells in the worksheet. The new data will overwrite values and formulas in the target worksheet cells, but existing formatting will be preserved. |
Nested Classes
Name | Description |
---|---|
Defines a set of constants related to worksheets. | |
A SheetViewState value specifies the view state of a worksheet in Excel. | |
A SheetVisibility value specifies the visibility level of a worksheet. | |
A SummaryColumnsLocation value specifies the location of the summary column for a set of grouped columns. | |
A SummaryColumnsLocation value specifies the location of the summary row for a set of grouped rows. |