Click or drag to resize

IWorksheet Properties

The IWorksheet type exposes the following members.

Properties
Name Description
Public property ActivePane
Identifier of pane with active cell cursor.
Public property AllocatedRange
Returns a Range object that represents a cell or a range of cells.
Public property AutoFilters
Returns collection of worksheet's autofilters. Read-only.
Public property Cells
Returns all used cells in the worksheet. Read-only.
Public property CheckBoxes
Returns collection with all checkboxes inside this worksheet. Read-only.
(Inherited from ITabSheet .)
Public property CodeName
Name that is used by macros to access the workbook items.
Public property Columns
For a Worksheet object, returns an array of Range objects that represents all the columns on the specified worksheet. Read-only Range object.
Public property ComboBoxes
Returns collection with all comboboxes inside this worksheet. Read-only.
(Inherited from ITabSheet .)
Public property Code example Comments
Comments collection.
Examples
The following code illustrates how to access the comments collection in the worksheet:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Adding comments to a cell.</para><para>ICommentShape comment1 = worksheet.Range["A1"].AddComment();</para><para>ICommentShape comment2 = worksheet.Range["B1"].AddComment();</para><para>//Set comment text</para><para>comment1.Text = "Comment1";</para><para>comment2.Text = "Comment2";</para><para>//Check count</para><para>Console.Write(worksheet.Comments.Count);</para><para>//Save to file</para><para>workbook.SaveToFile("Comments.xlsx");</para>
Public property Code example DefaultColumnWidth
Returns or sets the standard (default) width of all the columns in the worksheet. Read/write Double.
Examples
The following code illustrates how to get the default column width:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Get column width</para><para>Console.Write(worksheet.DefaultColumnWidth);</para><para>//Set default width</para><para>worksheet.DefaultColumnWidth = 40;</para><para>//Save to file</para><para>workbook.SaveToFile("DefaultColumnWidth.xlsx");</para>
Public property Code example DefaultRowHeight
Returns the standard (default) height of all the rows in the worksheet, in points. Read/write Double.
Examples
The following code illustrates how to get the default row height:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Get row height</para><para>Console.Write(worksheet.DefaultRowHeight);</para><para>//Set default height</para><para>worksheet.DefaultRowHeight = 40;</para><para>//Save to file</para><para>workbook.SaveToFile("DefaultRowHeight.xlsx");</para>
Public property DisplayPageBreaks
True if page breaks (both automatic and manual) on the specified worksheet are displayed. Read / write Boolean.
Public property FirstVisibleColumn
Index to first visible column in right pane(s).
Public property FirstVisibleRow
Index to first visible row in bottom pane(s).
Public property FormulasVisible
Gets or sets a value indicating whether the formulas are visible.
Public property Code example GridLineColor
Gets / sets Grid line color.
Examples
The following code illustrates how to set the grid line color:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Set grid lines color</para><para>worksheet.GridLineColor = ExcelColors.Red;</para><para>//Save to file</para><para>workbook.SaveToFile("GridLineColor.xlsx");</para>
Public property Code example GridLinesVisible
True if gridlines are visible; False otherwise.
Examples
The following code illustrates how to set visibility for grid lines:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Set grid line visibility</para><para>worksheet.GridLinesVisible = false;</para><para>//Save to file</para><para>workbook.SaveToFile("GridLinesVisible.xlsx");</para>
Public property Code example HasOleObjects
Gets or sets a value indicating whether this instance is OLE object.
Examples
The following code illustrates how to access the IListObjects collection in the worksheet to add a new IOleObject and check Ole Object:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Create image stream</para><para>System.Drawing.Image image = System.Drawing.Image.FromFile("image.png");</para><para>//Add ole object</para><para>IOleObject oleObject = worksheet.OleObjects.Add("Shapes.xlsx", image, OleLinkType.Embed);</para><para>//Check HasOleObject.Output will be true.</para>
 Console.Write(worksheet.HasOleObjects);

 <para>//Save to file</para><para>workbook.SaveToFile("HasOleObjects.xlsx");</para>
Public property HorizontalSplit
Gets or sets the position of horizontal split in the worksheet.
Public property HPageBreaks
Returns an HPageBreaks collection that represents the horizontal page breaks on the sheet. Read-only.
Public property HyperLinks
Collection of all worksheet's hyperlinks.
Public property Index
Returns the index number of the object within the collection of similar objects. Read-only.
Public property IsDisplayZeros
True if zero values to be displayed False otherwise.
Public property IsPasswordProtected
Indicates if the worksheet is password protected.
(Inherited from ITabSheet .)
Public property IsRightToLeft
Indicates whether worksheet is displayed right to left.
(Inherited from ITabSheet .)
Public property IsSelected
Indicates whether tab of this sheet is selected. Read-only.
(Inherited from ITabSheet .)
Public property IsStringsPreserved
Indicates if all values in the workbook are preserved as strings.
Public property Item String
Get cell range.
Public property Item Int32, Int32
Gets / sets cell by row and index.
Public property Item Int32, Int32, Int32, Int32
Get cells range.
Public property Code example LeftVisibleColumn
Gets/sets left visible column of the worksheet.
Examples
The following code illustrates how to set the left visible column:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Set left visible column</para><para>worksheet.LeftVisibleColumn = 3;</para><para>//Get left visible column</para><para>Console.Write(worksheet.LeftVisibleColumn);</para><para>//Save to file</para><para>workbook.SaveToFile("LeftVisibleColumn.xlsx");</para>
Public property ListObjects
Gets collection of all list objects in the worksheet.
Public property Code example MergedCells
Returns all merged ranges. Read-only.
Examples
The following code illustrates how to get the merged ranges:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Merge cells</para><para>worksheet["C2:D2"].Merge();</para><para>worksheet["F3:G3"].Merge();</para><para>//Get merged ranges</para><para>IXLSRange[] mergedRanges = worksheet.MergedCells;</para><para>//Get merged range count . Output will be 2</para><para>Console.Write(mergedRanges.Length);</para><para>//Save to file</para><para>workbook.SaveToFile("MergedCells.xlsx");</para>
Public property Name
Gets / sets name of the tab sheet.
(Inherited from ITabSheet .)
Public property Names
For a Worksheet object, returns a Names collection that represents all the worksheet-specific names (names defined with the "WorksheetName!" prefix). Read-only Names object.
Public property Code example OleObjects
Gets the OLE objects.
Examples
The following code illustrates how to access the IListObjects collection in the worksheet to add a new IOleObject:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Create image stream</para><para>System.Drawing.Image image = System.Drawing.Image.FromFile("image.png");</para><para>//Add ole object</para><para>IOleObject oleObject = worksheet.OleObjects.Add("Shapes.xlsx", image, OleLinkType.Embed);</para><para>//Save to file</para><para>workbook.SaveToFile("OLEObjects.xlsx");</para>
Public property PageSetup
Returns a PageSetup object that contains all the page setup settings for the specified object. Read-only.
Public property Parent
Gets the parent object of the current instance.
(Inherited from IExcelApplication .)
Public property Pictures
Returns pictures collection. Read-only.
(Inherited from ITabSheet .)
Public property PivotTables
Returns pivot table collection containing all pivot tables in the worksheet. Read-only.
Public property ProtectContents
Indicates is current sheet is protected.
(Inherited from ITabSheet .)
Public property ProtectDrawingObjects
True if objects are protected. Read-only.
(Inherited from ITabSheet .)
Public property Protection
Gets protected options. Read-only. For sets protection options use "Protect" method.
(Inherited from ITabSheet .)
Public property ProtectScenarios
True if the scenarios of the current sheet are protected. Read-only.
(Inherited from ITabSheet .)
Public property RadioButtons
Returns collection with all option buttons inside this worksheet. Read-only.
(Inherited from ITabSheet .)
Public property Code example Range
Returns a Range object that represents the used range on the specified worksheet. Read-only.
Examples
The following code illustrates how to get used range on the specified worksheet:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Set text</para><para>worksheet["B2"].Text = "Text";</para><para>//Set Color</para><para>worksheet["J3"].Style.Color = Color.Red;</para><para>//Get used range . Output will be B2:J3</para><para>Console.Write(worksheet.Range.RangeAddressLocal);</para><para>//Save to file</para><para>workbook.SaveToFile("UsedRange.xlsx");</para>
Public property RowColumnHeadersVisible
True if row and column headers are visible; False otherwise.
Public property Rows
For a Worksheet object, returns an array of Range objects that represents all the rows on the specified worksheet. Read-only Range object.
Public property TabColor
Gets / sets tab color.
(Inherited from ITabSheet .)
Public property TabIndex
Returns index in the parent ITabSheets collection. Read-only.
(Inherited from ITabSheet .)
Public property TabKnownColor
Gets / sets tab color.
(Inherited from ITabSheet .)
Public property TextBoxes
Returns collection with all textboxes inside this worksheet. Read-only.
(Inherited from ITabSheet .)
Public property Code example TopVisibleRow
Gets/sets top visible row of the worksheet.
Examples
The following code illustrates how to set the top visible row:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Set top visible row</para><para>worksheet.TopVisibleRow = 5;</para><para>//Get top visible row</para><para>Console.Write(worksheet.TopVisibleRow);</para><para>//Save to file</para><para>workbook.SaveToFile("TopVisibleRow.xlsx");</para>
Public property Type
Returns or sets the worksheet type. Read-only ExcelSheetType.
Public property UseRangesCache
Indicates whether all created range objects should be cached. Default value is false.
Public property VerticalSplit
Gets or sets the position of vertical split in the worksheet.
Public property Visibility
Control visibility of worksheet to end user.
(Inherited from ITabSheet .)
Public property VPageBreaks
Returns a VPageBreaks collection that represents the vertical page breaks on the sheet. Read-only.
Public property Workbook
Returns parent workbook. Read-only.
(Inherited from ITabSheet .)
Public property Code example Zoom
Zoom factor of document. Value must be in range from 10 till 400.
Examples
The following code illustrates how to set zoom level of the sheet:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Set zoom</para><para>worksheet.Zoom = 200;</para><para>//Save to file</para><para>workbook.SaveToFile("Zoom.xlsx");</para>
Top
See Also