CellRange module
- class CellRange.CellRange
Bases:
XlsRange- AddComment
- <summary>
Adds a comment to the range.
</summary> <param name=”comment”>Comment to add</param>
- property Borders: BordersCollection
- <summary>
Returns a Borders collection that represents the borders of a style or a range of cells (including a range defined as part of a conditional format).
<example>The following code illustrates how to access Borders property of the Range: <code> //Create worksheet Workbook workbook = new Workbook(); Worksheet worksheet = workbook.Worksheets[0]; //Set text worksheet[“C2”].Text = “Sample”; //Set borders IBorders borders = worksheet[“C2”].Borders; //Set line style borders[BordersLineType.EdgeTop].LineStyle = LineStyleType.Thin; borders[BordersLineType.EdgeBottom].LineStyle = LineStyleType.Thin; //Set border color borders[BordersLineType.EdgeTop].Color = Color.Red; borders[BordersLineType.EdgeBottom].Color = Color.Red; //Save to file workbook.SaveToFile(“CellFormats.xlsx”); </code> </example>
</summary>
- property Comment: ExcelComment
- <summary>
Returns a Comment object that represents the comment associated with the cell in the upper-left corner of the range.
<example>The following code illustrates how to access Comments property of the Range: <code> //Create worksheet Workbook workbook = new Workbook(); Worksheet worksheet = workbook.Worksheets[0]; //Adding comments to a cell worksheet.Range[“A1”].AddComment().Text = “Comments”; //Add Rich Text Comments CellRange range = worksheet.Range[“A6”]; range.AddComment().RichText.Text = “RichText”; IRichTextString rtf = range.Comment.RichText; //Formatting first 4 characters IFont redFont = workbook.CreateFont(); redFont.IsBold = true; redFont.Color = Color.Red; rtf.SetFont(0, 3, redFont); //Save to file workbook.SaveToFile(“DataValidation.xlsx”); </code> </example>
</summary>
- Copy
- <summary>
Copies the range to the specified range.
</summary> <param name=”destRange”>Destination range</param> <returns>Destination range</returns>
- property EndCell: CellRange
- <summary>
- Returns a Range object that represents the cell at the end of the
region that contains the source range.
</summary>
- property EntireColumn: CellRange
- <summary>
- Returns a Range object that represents the entire column (or
columns) that contains the specified range.
</summary>
- property EntireRow: CellRange
- <summary>
Returns a Range object that represents the entire row (or rows) that contains the specified range.
</summary>
- 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 datetime.
</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 double.
</summary> <param name=”doubleValue”>Double value to search for</param> <param name=”formulaValue”>Indicates whether to find 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 whether include formula</param> <param name=”formulaValue”>Indicates whether include formula value</param> <returns>Found ranges</returns>
- FindAllTimeSpan(timeSpanValue: TimeSpan) ListCellRanges
- <summary>
Finds the cell with input timespan
</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 datetime.
</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 whether includes formula value to search for</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 to search for</param> <param name=”formulaValue”>Indicates whether includes formula value to search for</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>
- GetDependentRanges(isAll: bool) ListCellRanges
- GetReferRanges() ListReferRangeAreas
- Intersect(range: CellRange) CellRange
- <summary>
Get intersection range with the specified range.
</summary> <param name=”range”>Range which to intersect.</param> <returns>Range intersection.</returns>
- Merge
- <summary>
Creates a merged cell from the specified Range object.
<example>The following code illustrates how to check whether two ranges are mergable or not: <code> //Create worksheet Workbook workbook = new Workbook(); Worksheet worksheet = workbook.Worksheets[0]; //Merge range worksheet[“A2:B2”].Merge(); //Get mergable range IXLSRange mergableRange = worksheet[“A2”].MergeArea.Merge(worksheet[“C2”]); //Check mergable Area Console.Write(mergableRange.RangeAddressLocal); //Save to file workbook.SaveToFile(“Intersect.xlsx”); </code> </example>
</summary> <param name=”range”>The Range to merge with.</param> <returns>Merged ranges.</returns>
- property MergeArea: CellRange
- <summary>
Returns a Range object that represents the merged range containing the specified cell.
<example>The following code illustrates how to access MergeArea property: <code> //Create worksheet Workbook workbook = new Workbook(); Worksheet worksheet = workbook.Worksheets[0]; //Set text worksheet[“C2”].Text = “Sample text in cell”; //Set merge worksheet[“C2:D3”].Merge(); //Check merge area Console.Write(worksheet[“C2”].MergeArea.AddressLocal); </code> </example>
</summary>
- Move
- <summary>
Moves the cells to the specified Range.
</summary> <param name=”destination”>Destnation Range.</param>
- property RichText: RichText
- <summary>
Returns a RichTextString object that represents the rich text style.
<example>The following code illustrates how to set rich text formatting in the range: <code> //Create worksheet Workbook workbook = new Workbook(); Worksheet worksheet = workbook.Worksheets[0]; //Create style IStyle style = workbook.Styles.Add(“CustomStyle”); //Set rich text IRichTextString richText = worksheet[“C2”].RichText; richText.Text = “Sample text”; //Set rich text font IFont font = style.Font; font.IsBold = true; richText.SetFont(0, 5, font); //Save to file workbook.SaveToFile(“RichText.xlsx”); </code> </example>
</summary>
- SetDataValidation(dataValidation: Validation)
- <summary>
Sets data validation for the range.
</summary> <param name=”dv”>Data validation to set.</param>
- property Style: CellStyle
- <summary>
Returns a Style object that represents the style of the specified range.
<example>The following code illustrates how to the style of the specified range: <code> //Create worksheet Workbook workbook = new Workbook(); Worksheet worksheet = workbook.Worksheets[0]; //Set text worksheet[“C2”].Text = “Sample”; //Add and set style CellStyle style = workbook.Styles.Add(“BorderStyle”); style.Color = Color.Red; worksheet[“C2”].Style = style; //Save to file workbook.SaveToFile(“Style.xlsx”); </code> </example>
</summary>
- property Worksheet: Worksheet
- <summary>
- Returns a worksheet object that represents the worksheet
containing the specified range.
</summary>
- get_Item
- <summary>
Gets cell range. Row and column indexes are one-based.
</summary> <param name=”row”></param> <param name=”column”></param> <returns></returns>