Class Worksheet

Worksheet class

Encapsulates the object that represents a single worksheet.

public class Worksheet : IDisposable

Properties

NameDescription
ActiveCell { get; set; }Gets or sets the active cell in the worksheet.
AllowEditRanges { get; }Gets the allow edit range collection in the worksheet.
AutoFilter { get; }Represents auto filter for the specified worksheet.
BackgroundImage { get; set; }Gets and sets worksheet background image.
Cells { get; }Gets the Cells collection.
CellWatches { get; }Gets collection of cells on this worksheet being watched in the ‘watch window’.
Charts { get; }Gets a Chart collection
CheckBoxes { get; }Gets a CheckBox collection.
CodeName { get; set; }Gets worksheet code name.
Comments { get; }Gets the Comment collection.
ConditionalFormattings { get; }Gets the ConditionalFormattings in the worksheet.
CustomProperties { get; }Gets an object representing the identifier information associated with a worksheet.
DisplayRightToLeft { get; set; }Indicates if the specified worksheet is displayed from right to left instead of from left to right. Default is false.
DisplayZeros { get; set; }True if zero values are displayed.
ErrorCheckOptions { get; }Gets error check setting applied on certain ranges.
FirstVisibleColumn { get; set; }Represents first visible column index.
FirstVisibleRow { get; set; }Represents first visible row index.
HasAutofilter { get; }Indicates whether this worksheet has auto filter.
HorizontalPageBreaks { get; }Gets the HorizontalPageBreakCollection collection.
Hyperlinks { get; }Gets the HyperlinkCollection collection.
Index { get; }Gets the index of sheet in the worksheet collection.
IsGridlinesVisible { get; set; }Gets or sets a value indicating whether the gridlines are visible.Default is true.
IsOutlineShown { get; set; }Indicates whether to show outline.
IsPageBreakPreview { get; set; }Indicates whether the specified worksheet is shown in normal view or page break preview.
IsProtected { get; }Indicates if the worksheet is protected.
IsRowColumnHeadersVisible { get; set; }Gets or sets a value indicating whether the worksheet will display row and column headers. Default is true.
IsRulerVisible { get; set; }Indicates whether the ruler is visible. This property is only applied for page break preview.
IsSelected { get; set; }Indicates whether this worksheet is selected when the workbook is opened.
IsVisible { get; set; }Represents if the worksheet is visible.
ListObjects { get; }Gets all ListObjects in this worksheet.
Name { get; set; }Gets or sets the name of the worksheet.
OleObjects { get; }Represents a collection of OleObject in a worksheet.
Outline { get; }Gets the outline on this worksheet.
PageSetup { get; }Represents the page setup description in this sheet.
PaneState { get; }Indicates whether the pane has horizontal or vertical splits, and whether those splits are frozen.
Pictures { get; }Gets a Picture collection.
PivotTables { get; }Gets all pivot tables in this worksheet.
Protection { get; }Represents the various types of protection options available for a worksheet. Supports advanced protection options in ExcelXP and above version.
QueryTables { get; }Gets QueryTableCollection in the worksheet.
Scenarios { get; }Gets the collection of Scenario.
Shapes { get; }Returns all drawing shapes in this worksheet.
ShowFormulas { get; set; }Indicates whether to show formulas or their results.
Slicers { get; }Get the Slicer collection in the worksheet
SmartTagSetting { get; }Gets all SmartTagCollection objects of the worksheet.
SparklineGroupCollection { get; }(Obsolete.) Gets the sparkline group collection in the worksheet.
SparklineGroups { get; }Gets the sparkline groups in the worksheet.
TabColor { get; set; }Represents worksheet tab color.
TabId { get; set; }Specifies the internal identifier for the sheet.
TextBoxes { get; }Gets a TextBox collection.
Timelines { get; }Get the Timeline collection in the worksheet
TransitionEntry { get; set; }Indicates whether the Transition Formula Entry (Lotus compatibility) option is enabled.
TransitionEvaluation { get; set; }Indicates whether the Transition Formula Evaluation (Lotus compatibility) option is enabled.
Type { get; set; }Represents worksheet type.
UniqueId { get; set; }Gets and sets the unique id, it is same as {15DB5C3C-A5A1-48AF-8F25-3D86AC232D4F}.
Validations { get; }Gets the data validation setting collection in the worksheet.
VerticalPageBreaks { get; }Gets the VerticalPageBreakCollection collection.
ViewType { get; set; }Gets and sets the view type.
VisibilityType { get; set; }Indicates the visible state for this sheet.
Workbook { get; }Gets the workbook object which contains this sheet.
Zoom { get; set; }Represents the scaling factor in percentage. It should be between 10 and 400.

Methods

NameDescription
AddPageBreaks(string)Adds page break.
AdvancedFilter(bool, string, string, string, bool)Filters data using complex criteria.
AutoFitColumn(int)Autofits the column width.
AutoFitColumn(int, int, int)Autofits the column width.
AutoFitColumns()Autofits all columns in this worksheet.
AutoFitColumns(AutoFitterOptions)Autofits all columns in this worksheet.
AutoFitColumns(int, int)Autofits the columns width.
AutoFitColumns(int, int, AutoFitterOptions)Autofits the columns width.
AutoFitColumns(int, int, int, int)Autofits the columns width.
AutoFitColumns(int, int, int, int, AutoFitterOptions)Autofits the columns width.
AutoFitRow(int)Autofits the row height.
AutoFitRow(int, int, int)Autofits the row height.
AutoFitRow(int, int, int, AutoFitterOptions)Autofits the row height.
AutoFitRow(int, int, int, int)Autofits row height in a rectangle range.
AutoFitRows()Autofits all rows in this worksheet.
AutoFitRows(AutoFitterOptions)Autofits all rows in this worksheet.
AutoFitRows(bool)Autofits all rows in this worksheet.
AutoFitRows(int, int)Autofits row height in a range.
AutoFitRows(int, int, AutoFitterOptions)Autofits row height in a range.
CalculateArrayFormula(string, CalculationOptions)Calculates a formula as array formula.
CalculateArrayFormula(string, CalculationOptions, int, int)Calculates a formula as array formula.
CalculateArrayFormula(string, FormulaParseOptions, CalculationOptions, int, int, int, int, CalculationData)Calculates a formula as array formula.
CalculateFormula(string)Calculates a formula.
CalculateFormula(CalculationOptions, bool)Calculates all formulas in this worksheet.
CalculateFormula(string, CalculationOptions)Calculates a formula expression directly.
CalculateFormula(string, FormulaParseOptions, CalculationOptions, int, int, CalculationData)Calculates a formula expression directly.
ClearComments()Clears all comments in designer spreadsheet.
CloseAccessCache(AccessCacheOptions)Closes the session that uses caches to access the data in this worksheet.
ConvertFormulaReferenceStyle(string, bool, int, int)Converts the formula reference style.
Copy(Worksheet)Copies contents and formats from another worksheet.
Copy(Worksheet, CopyOptions)Copies contents and formats from another worksheet.
Dispose()Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
FreezePanes(string, int, int)Freezes panes at the specified cell in the worksheet.
FreezePanes(int, int, int, int)Freezes panes at the specified cell in the worksheet.
GetFreezedPanes(out int, out int, out int, out int)Gets the freeze panes.
GetPanes()Gets the window panes.
GetPrintingPageBreaks(ImageOrPrintOptions)Gets automatic page breaks.
GetSelectedRanges()Gets selected ranges of cells in the designer spreadsheet.
MoveTo(int)Moves the sheet to another location in the spreadsheet.
Protect(ProtectionType)Protects worksheet.
Protect(ProtectionType, string, string)Protects worksheet.
RefreshPivotTables()Refreshes all the PivotTables in this Worksheet.
RemoveAllDrawingObjects()Removes all drawing objects in this worksheet.
RemoveAutoFilter()Removes the auto filter of the worksheet.
RemoveSplit()Removes split window.
Replace(string, string)Replaces all cells’ text with a new string.
SelectRange(int, int, int, int, bool)Selects a range.
SetBackground(byte[])(Obsolete.) Sets worksheet background image.
SetVisible(bool, bool)Sets the visible options.
Split()Splits window.
StartAccessCache(AccessCacheOptions)Starts the session that uses caches to access the data in this worksheet.
override ToString()Returns a string represents the current Worksheet object.
UnFreezePanes()Unfreezes panes in the worksheet.
Unprotect()Unprotects worksheet.
Unprotect(string)Unprotects worksheet.
XmlMapQuery(string, XmlMap)Query cell areas that mapped/linked to the specific path of xml map.

Examples

The following example shows how to freeze panes and insert hyperlink to worksheet with .Net or VB.

[C#]

Workbook workbook = new Workbook();

Worksheet sheet = workbook.Worksheets[0];

//Freeze panes at "AS40" with 10 rows and 10 columns
sheet.FreezePanes("AS40", 10, 10);

//Add a hyperlink in Cell A1
sheet.Hyperlinks.Add("A1", 1, 1, "http://www.aspose.com");

[Visual Basic]

Dim workbook as Workbook = new Workbook()

Dim sheet as Worksheet = workbook.Worksheets(0)

'Freeze panes at "AS40" with 10 rows and 10 columns
sheet.FreezePanes("AS40", 10, 10)

'Add a hyperlink in Cell A1
sheet.Hyperlinks.Add("A1", 1, 1, "http://www.aspose.com")

See Also