Worksheet module
- class Worksheet.Worksheet
Bases:
XlsWorksheet- property AllocatedRange: CellRange
- <summary>
- Returns a Range object that represents the used range on the
specified worksheet. Read-only.
</summary>
- ApplyStyle(style: CellStyle)
- <summary>
Apply style to whole sheet.
</summary> <param name=”style”>style to apply</param>
- property AutoFilters: AutoFiltersCollection
- CalculateAndGetRowHeight(rowIndex: int) float
- property Cells: ListCellRanges
- <summary>
Returns all used cells in the worksheet. Read-only.
</summary>
- property Charts: WorksheetChartsCollection
- <summary>
Returns charts collection. Read-only.
</summary>
- property Columns: ListCellRanges
- <summary>
Rrepresents all used columns on the specified worksheet. Read-only Range object.
</summary>
- property Comments: CommentsCollection
- <summary>
Returns comments collection for this worksheet. Read-only.
<example>The following code illustrates how to access the comments collection in the worksheet: <code> //Create worksheet Workbook workbook = new Workbook(); Worksheet worksheet = workbook.Worksheets[0]; //Adding comments to a cell. ICommentShape comment1 = worksheet.Range[“A1”].AddComment(); ICommentShape comment2 = worksheet.Range[“B1”].AddComment(); //Set comment text comment1.Text = “Comment1”; comment2.Text = “Comment2”; //Check count Console.Write(worksheet.Comments.Count); //Save to file workbook.SaveToFile(“Comments.xlsx”); </code> </example>
</summary>
- Copy
- <summary>
Copys data from a source range to a destination range.
</summary> <param name=”sourceRange”>Source range.</param> <param name=”destRange”>Destination range.</param>
- CopyColumn(sourceColumn: CellRange, destSheet: Worksheet, destColIndex: int, copyOptions: CopyRangeOptions)
- <summary>
Copys data from a source column to a destination column.
</summary> <param name=”sourceColumn”>Source column.</param> <param name=”destSheet”>Destination sheet</param> <param name=”destColIndex”>Destination column index</param> <param name=”copyOptions”>Copy options.</param>
- CopyFrom(worksheet: Worksheet)
- <summary>
Copy data from specified worksheet.
</summary> <param name=”worksheet”>worksheet object</param>
- CopyRow(sourceRow: CellRange, destSheet: Worksheet, destRowIndex: int, copyOptions: CopyRangeOptions)
- <summary>
Copys data from a source row to a destination row.
</summary> <param name=”sourceRow”>Source row.</param> <param name=”destSheet”>Destination sheet</param> <param name=”destRowIndex”>Destination row index</param> <param name=”copyOptions”>Copy options.</param>
- FindAll(findValue: str, flags: FindType, findOptions: ExcelFindOptions) ListCellRanges
- <summary>
Finds the all cells with specified string value.
</summary> <param name=”findValue”>Value to search.</param> <param name=”flags”>Type of value to search.</param> <param name=”findOptions”>Way to search.</param> <returns>All found cells, or Null if value was not found.</returns>
- FindAllBool(boolValue: bool) ListCellRanges
- <summary>
Finds the cell with the input bool.
</summary> <param name=”boolValue”>Bool value to search for.</param> <returns>Found ranges.</returns>
- FindAllDateTime(dateTimeValue: DateTime) ListCellRanges
- <summary>
Finds the cell with the input date time.
</summary> <param name=”dateTimeValue”>Datetime value to search for.</param> <returns>Found ranges.</returns>
- FindAllNumber(doubleValue: float, formulaValue: bool) ListCellRanges
- <summary>
Finds the cell with the input number.
</summary> <param name=”doubleValue”>Double value to search for.</param> <param name=”formulaValue”>Indicates if includes formula value.</param> <returns>Found ranges.</returns>
- FindAllString(stringValue: str, formula: bool, formulaValue: bool) ListCellRanges
- <summary>
Finds the cell with the input string.
</summary> <param name=”stringValue”>String value to search for.</param> <param name=”formula”>Indicates if includes formula.</param> <param name=”formulaValue”>Indicates if includes formula value.</param> <returns>Found ranges.</returns>
- FindAllTimeSpan(timeSpanValue: TimeSpan) ListCellRanges
- <summary>
Finds the cell with the input time span.
</summary> <param name=”timeSpanValue”>Time span value to search for.</param> <returns>Found ranges.</returns>
- FindBool(boolValue: bool) CellRange
- <summary>
Finds the cell with the input bool.
</summary> <param name=”boolValue”>Bool value to search for.</param> <returns>Found range.</returns>
- FindDateTime(dateTimeValue: DateTime) CellRange
- <summary>
Finds the cell with the input date time.
</summary> <param name=”dateTimeValue”>DateTime value to search for.</param> <returns>Found range.</returns>
- FindNumber(doubleValue: float, formulaValue: bool) CellRange
- <summary>
Finds the cell with the input double.
</summary> <param name=”doubleValue”>Double value to search for.</param> <param name=”formulaValue”>Indicates if includes formula value.</param> <returns>Found range.</returns>
- FindString(stringValue: str, formula: bool, formulaValue: bool) CellRange
- <summary>
Finds the cell with the input string.
</summary> <param name=”stringValue”>String value to search for.</param> <param name=”formula”>Indicates whether includes formula.</param> <param name=”formulaValue”>Indicates whether includes formula value.</param> <returns>Found range.</returns>
- FindTimeSpan(timeSpanValue: TimeSpan) CellRange
- <summary>
Finds the cell with the input time span.
</summary> <param name=”timeSpanValue”>Time span value to search for.</param> <returns>Found range.</returns>
- FreezePanes(rowIndex: int, columnIndex: int)
- <summary>
Freezes panes at the specified cell in the worksheet.
</summary> <param name=”rowIndex”>Row index.</param> <param name=”columnIndex”>Column index.</param>
- GetDefaultColumnStyle(columnIndex: int) CellStyle
- <summary>
Returns default column style.
<example>The following code illustrates how to get default column style: <code> //Create worksheet Workbook workbook = new Workbook(); Worksheet worksheet = workbook.Worksheets[0]; //Create style CellStyle style = workbook.Styles.Add(“CustomStyle”); //Set Color style.Color = Color.Red; //Set default style worksheet.SetDefaultColumnStyle(2,style); //Get default style CellStyle defaultStyle = worksheet.GetDefaultColumnStyle(2); //Set color defaultStyle.Color = Color.Blue; worksheet.SetDefaultColumnStyle(3, defaultStyle); //Save to file workbook.SaveToFile(“GetDefaultColumnStyle.xlsx”); </code> </example>
</summary> <param name=”columnIndex”>Column index.</param> <returns>Default column style or null if default style is not exists.</returns>
- GetDefaultRowStyle(rowIndex: int) CellStyle
- <summary>
Returns default row style.
<example>The following code illustrates how to get default row style: <code> //Create worksheet Workbook workbook = new Workbook(); Worksheet worksheet = workbook.Worksheets[0]; //Create style CellStyle style = workbook.Styles.Add(“CustomStyle”); //Set Color style.Color = Color.Red; //Set default style worksheet.SetDefaultRowStyle(2,style); //Get default style CellStyle defaultStyle = worksheet.GetDefaultRowStyle(2); //Set color defaultStyle.Color = Color.Blue; worksheet.SetDefaultRowStyle(3, defaultStyle); //Save to file workbook.SaveToFile(“GetDefaultColumnStyle.xlsx”); </code> </example>
</summary> <param name=”rowIndex”>Row index.</param> <returns>Default row style or null if default style is not set.</returns>
- GetFreezePanes() List[int]
- GetIntersectRanges(range1: CellRange, range2: CellRange) CellRange
- <summary>
Intersects two ranges.
</summary> <param name=”range1”>First range.</param> <param name=”range2”>Second range.</param> <returns>Intersection of two ranges</returns>
- property GroupShapeCollection: GroupShapeCollection
- <summary>
Get group shapes in worksheet.
</summary>
- property HPageBreaks: HPageBreaksCollection
- <summary>
- Returns an HPageBreaks collection that represents the horizontal
page breaks on the sheet.
</summary>
- property HyperLinks: HyperLinksCollection
- <summary>
Collection of all worksheet’s hyperlinks.
</summary>
- Merge(range1: CellRange, range2: CellRange) CellRange
- <summary>
Combines a range of cells into a single cell.
</summary> <param name=”range1”>First range.</param> <param name=”range2”>Second range.</param> <returns>Merged ranges</returns>
- property MergedCells: ListCellRanges
- <summary>
Returns all merged ranges. Read-only.
<example>The following code illustrates how to get the merged ranges: <code> //Create worksheet Workbook workbook = new Workbook(); Worksheet worksheet = workbook.Worksheets[0]; //Merge cells worksheet[“C2:D2”].Merge(); worksheet[“F3:G3”].Merge(); //Get merged ranges IXLSRange[] mergedRanges = worksheet.MergedCells; //Get merged range count . Output will be 2 Console.Write(mergedRanges.Length); //Save to file workbook.SaveToFile(“MergedCells.xlsx”); </code> </example>
</summary>
- Move
- <summary>
Move data from source range to destination range.
</summary> <param name=”sourceRange”>Source range.</param> <param name=”destRange”>Destination range.</param>
- property PageSetup: PageSetup
- <summary>
- Returns a PageSetup object that contains all the page setup settings
for the specified object. Read-only.
</summary>
- property ParentWorkbook: Workbook
- property Pictures: PicturesCollection
- <summary>
Pictures collection. Read-only.
</summary>
- property PrintRange: CellRange
- <summary>
Print area of worksheet.
</summary>
- property QueryTables: QueryTableCollection
- property Range: CellRange
- <summary>
- Returns a Range object that represents the used range on the
specified worksheet. Read-only.
<example>The following code illustrates how to get used range on the specified worksheet: <code> //Create worksheet Workbook workbook = new Workbook(); Worksheet worksheet = workbook.Worksheets[0]; //Set text worksheet[“B2”].Text = “Text”; //Set Color worksheet[“J3”].Style.Color = Color.Red; //Get used range . Output will be B2:J3 Console.Write(worksheet.Range.RangeAddressLocal); //Save to file workbook.SaveToFile(“UsedRange.xlsx”); </code> </example>
</summary>
- RemoveMergedCells(range: CellRange)
- RemovePicture
- <summary>
Remove picture from this worksheet.
</summary> <param name=”index”>Picture ID</param>
- RemoveRange
- <summary>
Removes range from list.
</summary> <param name=”range”>Specified range.</param>
- property Rows: ListCellRanges
- <summary>
Represents all the rows on the specified worksheet. Read-only Range object.
</summary>
- SetActiveCell(range: CellRange)
- <summary>
Sets active cell
</summary> <param name=”range”>Cell to activate.</param>
- SetDefaultColumnStyle
- <summary>
Sets default style for column.
<example>The following code illustrates how to set the default style for a column: <code> //Create worksheet Workbook workbook = new Workbook(); Worksheet worksheet = workbook.Worksheets[0]; //Create style CellStyle style = workbook.Styles.Add(“CustomStyle”); //Set Color style.Color = Color.Red; //Set default style worksheet.SetDefaultColumnStyle(2, style); //Save to file workbook.SaveToFile(“SetDefaultColumnStyle.xlsx”); </code> </example>
</summary> <param name=”columnIndex”>Column index.</param> <param name=”defaultStyle”>Default style.</param>
- SetDefaultRowStyle
- <summary>
Sets default style for row.
<example>The following code illustrates how to set the default style for a row: <code> //Create worksheet Workbook workbook = new Workbook(); Worksheet worksheet = workbook.Worksheets[0]; //Create style CellStyle style = workbook.Styles.Add(“CustomStyle”); //Set Color style.Color = Color.Red; //Set default style worksheet.SetDefaultRowStyle(2, style); //Save to file workbook.SaveToFile(“SetDefaultRowStyle.xlsx”); </code> </example>
</summary> <param name=”rowIndex”>Row index.</param> <param name=”defaultStyle”>Default style.</param>
- property VPageBreaks: VPageBreaksCollection
- <summary>
- Returns a VPageBreaks collection that represents the vertical page
breaks on the sheet. Read-only.
</summary>
- property Workbook: Workbook
- get_Item
- <summary>
Get cell range.
</summary> <param name=”row”></param> <param name=”column”></param> <param name=”lastRow”></param> <param name=”lastColumn”></param> <returns></returns>