IXLSRanges Interface |
Namespace: Spire.Xls.Core
The IXLSRanges type exposes the following members.
| Name | Description | |
|---|---|---|
|
|
BooleanValue |
Gets / sets boolean value that is contained by this range.
(Inherited from
IXLSRange
.)
The following code illustrates how to access Boolean property of the Range:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Set and get BooleanValue</para><para>worksheet.Range[2, 4].BooleanValue = true;</para><para>bool boolean = worksheet.Range[2, 4].BooleanValue;</para>
|
|
|
Borders |
Returns aBorders collection that represents the borders of a style
or a range of cells (including a range defined as part of a
conditional format).
(Inherited from
IXLSRange
.)
The following code illustrates how to access Borders property of the Range:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Set text</para><para>worksheet["C2"].Text = "Sample";</para><para>//Set borders</para><para>IBorders borders = worksheet["C2"].Borders;</para><para>//Set line style</para><para>borders[BordersLineType.EdgeTop].LineStyle = LineStyleType.Thin;</para><para>borders[BordersLineType.EdgeBottom].LineStyle = LineStyleType.Thin;</para><para>//Set border color</para><para>borders[BordersLineType.EdgeTop].Color = Color.Red;</para><para>borders[BordersLineType.EdgeBottom].Color = Color.Red;</para><para>//Save to file</para><para>workbook.SaveToFile("CellFormats.xlsx");</para>
|
|
|
BuiltInStyle |
Gets/sets built in style.
(Inherited from
IXLSRange
.)
The following code illustrates how to access BuiltInStyle property:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Set text</para><para>worksheet["C2"].Text = "Sample";</para><para>//Set built in style</para><para>worksheet["C2"].BuiltInStyle = BuiltInStyles.Accent3;</para><para>//Save to file</para><para>workbook.SaveToFile("BuiltInStyle.xlsx");</para>
|
|
|
CellList |
Returns a Range object that represents the cells in the specified range.
Read-only.
(Inherited from
IXLSRange
.)
The following code illustrates how to access CellList property of the Range:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Set text. The content contained by ![CDATA[]] will be expressed as plain text</para><para>ListCellRange cells = worksheet["A1:E8"].CellList;</para><para>//Do some manipulations</para><para>foreach (CellRange Range in cells)</para><para>Range.Text = Range.RangeAddressLocal;</para><para>//Save to file</para><para>workbook.SaveToFile("CellList.xlsx");</para>
|
|
|
Cells |
Obsolete.
Returns a Range object that represents the cells in the specified range.
Read-only.
(Inherited from
IXLSRange
.)
|
|
|
CellStyleName |
Returns name of the Style object that represents the style of the specified
range. Read/write String.
(Inherited from
IXLSRange
.)
The following code illustrates how to access CellStyleName of the specified range:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Add and set style</para><para>CellStyle style = workbook.Styles.Add("CustomStyle");</para><para>worksheet["C2"].Style = style;</para><para>//Check Style name</para><para>Console.Write(worksheet["C2"].CellStyleName);</para>
|
|
|
Column |
Returns the number of the first column in the first area in the specified
range. Read-only.
(Inherited from
IXLSRange
.)
The following code illustrates how to access Column property of the Range:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Get specific column</para><para>int firstColumn = worksheet["E1:R3"].Column;</para>
|
|
|
ColumnGroupLevel |
Column group level. Read-only.
-1 - Not all columns in the range have same group level.
0 - No grouping,
1 - 7 - Group level.
(Inherited from
IXLSRange
.)
|
|
|
Columns |
For a Range object, returns an array of Range objects that represent the
columns in the specified range.
(Inherited from
IXLSRange
.)
The following code illustrates how to access columns:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Set columns</para><para>IXLSRange[] columns = worksheet["A1:E8"].Columns;</para><para>//Do some manipulations</para><para>foreach (IXLSRange column in columns)</para><para>column.Text = column.RangeAddressLocal;</para><para>//Save to file</para><para>workbook.SaveToFile("Columns.xlsx");</para>
|
|
|
ColumnWidth |
Returns or sets the width of all columns in the specified range.
Read/write Double.
(Inherited from
IXLSRange
.)
The following code illustrates how to set the width of all columns in the specified range:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Set the ColumnWidth</para><para>worksheet["A1"].Text = "This cell contains sample text";</para><para>worksheet["A1"].ColumnWidth = 25;</para><para>//Save to file</para><para>workbook.SaveToFile("ColumnWidth.xlsx");</para>
|
|
|
Comment |
Comment assigned to the range. Read-only.
(Inherited from
IXLSRange
.)
The following code illustrates how to access Comments property of the Range:
<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>worksheet.Range["A1"].AddComment().Text = "Comments";</para><para>//Add Rich Text Comments</para><para>CellRange range = worksheet.Range["A6"];</para><para>range.AddComment().RichText.Text = "RichText";</para><para>IRichTextString rtf = range.Comment.RichText;</para><para>//Formatting first 4 characters</para><para>IFont redFont = workbook.CreateFont();</para><para>redFont.IsBold = true;</para><para>redFont.Color = Color.Red;</para><para>rtf.SetFont(0, 3, redFont);</para><para>//Save to file</para><para>workbook.SaveToFile("DataValidation.xlsx");</para>
|
|
|
ConditionalFormats |
Collection of conditional formats.
(Inherited from
IXLSRange
.)
|
|
|
Count |
Returns the number of objects in the collection. Read-only.
(Inherited from
IXLSRange
.)
|
|
|
DataValidation |
Data validation for the range.
(Inherited from
IXLSRange
.)
The following code illustrates how to access DataValidation property of the Range:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Data validation for number</para><para>IDataValidation validation = worksheet.Range["A3"].DataValidation;</para><para>validation.AllowType = CellDataType.Integer;</para><para>//Value between 0 to 10</para><para>validation.CompareOperator = ValidationComparisonOperator.Between;</para><para>validation.Formula1 = "0";</para><para>validation.Formula2 = "10";</para><para>//Save to file</para><para>workbook.SaveToFile("DataValidation.xlsx");</para>
|
|
|
DateTimeValue |
Gets / sets DateTime contained by this cell. Read-write DateTime.
(Inherited from
IXLSRange
.)
The following code illustrates how to set and access DateTimeValue property of the Range:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Set and get the DateTimeValue of specified range</para><para>worksheet.Range[2, 4].DateTimeValue = DateTime.Now;</para><para>DateTime dateTime = worksheet.Range[2, 4].DateTimeValue;</para><para>//Save to file</para><para>workbook.SaveToFile("DateTimeValue.xlsx");</para>
|
|
|
EndCell |
Returns a Range object that represents the cell at the end of the
region that contains the source range.
(Inherited from
IXLSRange
.)
|
|
|
EntireColumn |
Returns a Range object that represents the entire column (or
columns) that contains the specified range. Read-only.
(Inherited from
IXLSRange
.)
|
|
|
EntireRow |
Returns a Range object that represents the entire row (or
rows) that contains the specified range. Read-only.
(Inherited from
IXLSRange
.)
|
|
|
EnvalutedValue |
Returns the calculated value of a formula using the most current inputs.
(Inherited from
IXLSRange
.)
The following code illustrates how to access a calculated value:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>workbook.LoadFromFile("Sample.xlsx");</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Returns the calculated value of a formula using the most current inputs</para><para>string calculatedValue = worksheet["C1"].EnvalutedValue;</para><para>Console.WriteLine(calculatedValue);</para>
|
|
|
ErrorValue |
Gets / sets error value that is contained by this range.
(Inherited from
IXLSRange
.)
|
|
|
Formula |
Returns or sets the object's formula in A1-style notation and in
the language of the macro. Read/write Variant.
(Inherited from
IXLSRange
.)
|
|
|
FormulaArray |
Represents array-entered formula.
Visit http://www.cpearson.com/excel/array.htm for more information.
(Inherited from
IXLSRange
.)
The following code illustrates how to set and access FormulaArray property of the range:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Assign array formula</para><para>worksheet.Range["A1:D1"].FormulaArray = "{1,2,3,4}";</para><para>//Adding a named range for the range A1 to D1</para><para>worksheet.Names.Add("ArrayRange", worksheet.Range["A1:D1"]);</para><para>//Assign formula array with named range</para><para>worksheet.Range["A2:D2"].FormulaArray = "ArrayRange+100";</para><para>//Save to file</para><para>workbook.SaveToFile("FormulaArray.xlsx");</para>
|
|
|
FormulaArrayR1C1 |
Returns or sets the formula array for the range, using R1C1-style notation.
(Inherited from
IXLSRange
.)
|
|
|
FormulaBoolValue |
Returns the calculated value of the formula as a boolean.
(Inherited from
IXLSRange
.)
|
|
|
FormulaDateTime |
Get / set formula DateTime value contained by this cell.
DateTime.MinValue if not all cells of the range have same DateTime value.
(Inherited from
IXLSRange
.)
|
|
|
FormulaErrorValue |
Returns the calculated value of the formula as a string.
(Inherited from
IXLSRange
.)
|
|
|
FormulaNumberValue |
Gets / sets number value evaluated by formula.
(Inherited from
IXLSRange
.)
|
|
|
FormulaR1C1 |
Returns or sets the formula for the range, using R1C1-style notation.
(Inherited from
IXLSRange
.)
|
|
|
FormulaStringValue |
Gets / sets string value evaluated by formula.
(Inherited from
IXLSRange
.)
|
|
|
HasBoolean |
Indicates whether range contains bool value. Read-only.
(Inherited from
IXLSRange
.)
The following code illustrates how to set and access HasBoolean property of the Range:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Assigning Value2 property of the Range</para><para>worksheet["A3"].Value2 = false;</para><para>//Checking Range types</para><para>bool isboolean = worksheet["A3"].HasBoolean;</para><para>//Save to file</para><para>workbook.SaveToFile("HasBoolean.xlsx");</para>
|
|
|
HasDataValidation |
Indicates whether specified range object has data validation.
If Range is not single cell, then returns true only if all cells have data validation. Read-only.
(Inherited from
IXLSRange
.)
|
|
|
HasDateTime |
Indicates whether range contains DateTime value. Read-only.
(Inherited from
IXLSRange
.)
The following code illustrates how to set and access HasDateTime property of the Range:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Assigning Value2 property of the Range</para><para>worksheet["A1"].Value2 = DateTime.Now;</para><para>//Checking Range types</para><para>bool isDateTime =worksheet["A1"].HasDateTime;</para><para>//Save to file</para><para>workbook.SaveToFile("HasDateTime.xlsx");</para>
|
|
|
HasError |
Indicates whether range contains error value.
(Inherited from
IXLSRange
.)
|
|
|
HasExternalFormula |
Indicates is current range has external formula. Read-only.
(Inherited from
IXLSRange
.)
|
|
|
HasFormula |
True if all cells in the range contain formulas; False if
at least one of the cells in the range doesn't contain a formula.
Read-only Boolean.
(Inherited from
IXLSRange
.)
|
|
|
HasFormulaArray |
Indicates whether range contains array-entered formula. Read-only.
(Inherited from
IXLSRange
.)
|
|
|
HasFormulaBoolValue |
Indicates if current range has formula bool value. Read only.
(Inherited from
IXLSRange
.)
|
|
|
HasFormulaDateTime |
Indicates if current range has formula value formatted as DateTime. Read-only.
(Inherited from
IXLSRange
.)
|
|
|
HasFormulaErrorValue |
Indicates if current range has formula error value. Read only.
(Inherited from
IXLSRange
.)
|
|
|
HasFormulaNumberValue |
Indicates if the current range has formula number value. Read-only.
(Inherited from
IXLSRange
.)
|
|
|
HasFormulaStringValue |
Indicates if the current range has formula string value. Read-only.
(Inherited from
IXLSRange
.)
|
|
|
HasMerged |
Indicates whether this range is part of merged range. Read-only.
(Inherited from
IXLSRange
.)
The following code illustrates how to access HasMerged property:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Set text</para><para>worksheet["A1"].Text = "Sample text in cell";</para><para>//Set merge</para><para>worksheet["A1:B1"].Merge();</para><para>//Check merge</para><para>Console.Write(worksheet["A1:B1"].HasMerged);</para>
|
|
|
HasNumber |
Indicates whether the range contains number. Read-only.
(Inherited from
IXLSRange
.)
The following code illustrates how to set and access Value2 property of the Range:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Assigning Value2 property of the Range</para><para>worksheet["A2"].Value2 = 45;</para><para>//Checking Range types</para><para>bool isNumber =worksheet["A2"].HasNumber;</para><para>//Save to file</para><para>workbook.SaveToFile("HasNumber.xlsx");</para>
|
|
|
HasRichText |
Indicates whether cell contains formatted rich text string.
(Inherited from
IXLSRange
.)
The following code illustrates how to access HasRichText property:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Create style</para><para>IStyle style = workbook.Styles.Add("CustomStyle");</para><para>//Set rich text</para><para>IRichTextString richText = worksheet["C2"].RichText;</para><para>richText.Text = "Sample";</para><para>IFont font = style.Font;</para><para>font.Color = Color.Red;</para><para>richText.SetFont(0, 5, font);</para><para>//Check HasRichText</para><para>Console.Write(worksheet["C2"].HasRichText);</para><para>//Save to file</para><para>workbook.SaveToFile("HasRichText.xlsx");</para>
|
|
|
HasString |
Indicates whether the range contains String. Read-only.
(Inherited from
IXLSRange
.)
|
|
|
HasStyle |
Indicates whether range has default style. False means default style.
Read-only.
(Inherited from
IXLSRange
.)
The following code illustrates how to access HasStyle property:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Add style</para><para>CellStyle style = workbook.Styles.Add("CustomStyle");</para><para>//Set color and style</para><para>style.Color = Color.Red;</para><para>worksheet["C2"].Style = style;</para><para>//Check HasStyle</para><para>Console.Write(worksheet["C2"].HasStyle);</para><para>//Save to file</para><para>workbook.SaveToFile("HasStyle.xlsx");</para>
|
|
|
HorizontalAlignment |
Returns or sets the horizontal alignment for the specified object.
Read/write HorizontalAlignType.
(Inherited from
IXLSRange
.)
The following code illustrates how to set alignment type:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Set text</para><para>worksheet["A1"].Text = "Test";</para><para>//Set alignment</para><para>worksheet["A1"].HorizontalAlignment = HorizontalAlignType.Right;</para><para>//Save to file</para><para>workbook.SaveToFile("HorizontalAlignment.xlsx");</para>
|
|
|
HtmlString |
Gets and sets the html string which contains data and some formattings in this cell.
(Inherited from
IXLSRange
.)
|
|
|
Hyperlinks |
Returns hyperlinks for this range.
(Inherited from
IXLSRange
.)
|
|
|
IgnoreErrorOptions |
Represents ignore error options.
(Inherited from
IXLSRange
.)
|
|
|
IndentLevel |
Returns or sets the indent level for the cell or range. Can be an
integer from 0 to 15. Read/write Integer.
(Inherited from
IXLSRange
.)
The following code illustrates how to set indent level for a cell:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Set text</para><para>worksheet["C2"].Text = "Sample";</para><para>//Set indent level</para><para>worksheet["C2"].IndentLevel = 2;</para><para>//Save to file</para><para>workbook.SaveToFile("IndentLevel.xlsx");</para>
|
|
|
IsBlank |
Indicates whether the range is blank. Read-only.
(Inherited from
IXLSRange
.)
|
|
|
IsFormulaHidden |
True if the formula will be hidden when the worksheet is protected.
False if at least part of formula in the range is not hidden.
(Inherited from
IXLSRange
.)
|
|
|
IsGroupedByColumn |
Indicates whether this range is grouped by column. Read-only.
(Inherited from
IXLSRange
.)
|
|
|
IsGroupedByRow |
Indicates whether this range is grouped by row. Read-only.
(Inherited from
IXLSRange
.)
|
|
|
IsInitialized |
Indicates whether cell is initialized. Read-only.
(Inherited from
IXLSRange
.)
|
|
|
IsStringsPreserved |
Indicates whether all values in the range are preserved as strings.
(Inherited from
IXLSRange
.)
|
|
|
IsWrapText |
True if Microsoft Excel wraps the text in the object.
Read/write Boolean.
(Inherited from
IXLSRange
.)
The following code illustrates how to access WrapText property:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Set text</para><para>worksheet["A1"].Text = "This cell contains sample text";</para><para>//Set wrap text</para><para>worksheet["A1"].IsWrapText = true;</para><para>//Save to file</para><para>workbook.SaveToFile("IsWrapText.xlsx");</para>
|
|
|
Item String |
Get cell range. Read-only.
(Inherited from
IXLSRange
.)
|
|
|
Item Int32 |
Returns item by index from the collection.
|
|
|
Item Int32, Int32 |
Gets / sets cell by row and column index. Row and column indexes are one-based.
(Inherited from
IXLSRange
.)
|
|
|
Item String, Boolean |
Gets cell range. Read-only.
(Inherited from
IXLSRange
.)
|
|
|
Item Int32, Int32, Int32, Int32 |
Get cell range. Row and column indexes are one-based. Read-only.
(Inherited from
IXLSRange
.)
|
|
|
LastColumn |
Returns last column of the range. Read-only.
(Inherited from
IXLSRange
.)
|
|
|
LastRow |
Returns last row of the range. Read-only.
(Inherited from
IXLSRange
.)
|
|
|
MergeArea |
Returns a Range object that represents the merged range containing
the specified cell. If the specified cell is not in a merged range,
this property returns NULL. Read-only.
(Inherited from
IXLSRange
.)
The following code illustrates how to access MergeArea property:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Set text</para><para>worksheet["C2"].Text = "Sample text in cell";</para><para>//Set merge</para><para>worksheet["C2:D3"].Merge();</para><para>//Check merge area</para><para>Console.Write(worksheet["C2"].MergeArea.AddressLocal);</para>
|
|
|
NumberFormat |
Format of current cell. Analog of Style.NumberFormat property.
(Inherited from
IXLSRange
.)
The following code illustrates how to set NumberFormat property:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Set data</para><para>worksheet["C2"].Value = "3100.23";</para><para>//Set number format</para><para>worksheet["C2"].NumberFormat = "#,##1.##";</para><para>//Save to file</para><para>workbook.SaveToFile("NumberFormat.xlsx");</para>
|
|
|
NumberText |
Returns cell value after number format application. Read-only.
(Inherited from
IXLSRange
.)
The following code illustrates how to access NumberText property of the Range:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Gets cell value with its number format</para><para>CellRange range= worksheet.Range[3, 1];</para><para>range.Value = "1/1/2015";</para><para>range.NumberFormat = "dd-MMM-yyyy";</para><para>string numberText = range.NumberText;</para><para>//Save to file</para><para>workbook.SaveToFile("NumberText.xlsx");</para>
|
|
|
NumberValue |
Gets / sets double value of the range.
(Inherited from
IXLSRange
.)
|
|
|
Parent |
Gets the parent object of the current instance.
(Inherited from
IExcelApplication
.)
|
|
|
RangeAddress |
Returns the range reference in the language of the macro.
Read-only String.
(Inherited from
IXLSRange
.)
The following code illustrates how to access Address property of the Range:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Get RangeAddress</para><para>string address = worksheet.Range[3, 4].RangeAddress;</para>
|
|
|
RangeAddressLocal |
Returns the range reference for the specified range in the language
of the user. Read-only String.
(Inherited from
IXLSRange
.)
The following code illustrates how to access AddressLocal property of the Range:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Get RangeAddressLocal</para><para>string address = worksheet.Range[3, 4].RangeAddressLocal;</para>
|
|
|
RangeGlobalAddress |
Returns range Address in format "'Sheet1'!$A$1".
(Inherited from
IXLSRange
.)
The following code illustrates how to access AddressGlobal property of the Range:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Get RangeAddress</para><para>string address = worksheet.Range[3, 4].RangeGlobalAddress;</para>
|
|
|
RangeR1C1Address |
Returns the range reference using R1C1 notation.
Read-only String.
(Inherited from
IXLSRange
.)
The following code illustrates how to access AddressR1C1 property of the Range:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Get RangeR1C1Address</para><para>string address = worksheet.Range[3, 4].RangeR1C1Address;</para>
|
|
|
RangeR1C1AddressLocal |
Returns the range reference using R1C1 notation.
Read-only String.
(Inherited from
IXLSRange
.)
The following code illustrates how to access AddressR1C1Local property of the Range:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Get RangeR1C1AddressLocal</para><para>string address = worksheet.Range[3, 4].RangeR1C1Address;</para>
|
|
|
RichText |
String with rich text formatting. Read-only.
(Inherited from
IXLSRange
.)
The following code illustrates how to set rich text formatting in the range:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Create style</para><para>IStyle style = workbook.Styles.Add("CustomStyle");</para><para>//Set rich text</para><para>IRichTextString richText = worksheet["C2"].RichText;</para><para>richText.Text = "Sample text";</para><para>//Set rich text font</para><para>IFont font = style.Font;</para><para>font.IsBold = true;</para><para>richText.SetFont(0, 5, font);</para><para>//Save to file</para><para>workbook.SaveToFile("RichText.xlsx");</para>
|
|
|
Row |
Returns the number of the first row of the first area in
the range. Read-only Long.
(Inherited from
IXLSRange
.)
|
|
|
RowGroupLevel |
Row group level. Read-only.
-1 - Not all rows in the range have same group level.
0 - No grouping,
1 - 7 - Group level.
(Inherited from
IXLSRange
.)
|
|
|
RowHeight |
Returns the height of all the rows in the range specified,
measured in points. Returns Double.MinValue if the rows in the specified range
aren't all the same height. Read / write Double.
(Inherited from
IXLSRange
.)
The following code illustrates how to set row height:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Set text</para><para>worksheet["A1"].Text = "Test";</para><para>//Set row height</para><para>worksheet["A1"].RowHeight = 30;</para><para>//Save to file</para><para>workbook.SaveToFile("RowHeight.xlsx");</para>
|
|
|
Rows |
For a Range object, returns an array of Range objects that represent the
rows in the specified range.
(Inherited from
IXLSRange
.)
The following code illustrates how to access rows:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Set rows</para><para>IXLSRange[] rows = worksheet["A1:E8"].Rows;</para><para>//Do some manipulations</para><para>foreach (IXLSRange row in rows)</para><para>row.Text = row.RangeAddressLocal;</para><para>//Save to file</para><para>workbook.SaveToFile("Rows.xlsx");</para>
|
|
|
Style |
Returns a Style object that represents the style of the specified
range. Read/write IStyle.
(Inherited from
IXLSRange
.)
The following code illustrates how to the style of the specified range:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Set text</para><para>worksheet["C2"].Text = "Sample";</para><para>//Add and set style</para><para>CellStyle style = workbook.Styles.Add("BorderStyle");</para><para>style.Color = Color.Red;</para><para>worksheet["C2"].Style = style;</para><para>//Save to file</para><para>workbook.SaveToFile("Style.xlsx");</para>
|
|
|
Text |
Gets / sets string value of the range.
(Inherited from
IXLSRange
.)
|
|
|
TimeSpanValue |
Gets / sets time value of the range.
(Inherited from
IXLSRange
.)
|
|
|
Value |
Returns or sets the value of the specified range.
Read/write Variant.
(Inherited from
IXLSRange
.)
The following code illustrates how to set Value of the specified range:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Set value of the range</para><para>CellRange range= worksheet.Range[3, 1];</para><para>range.Value = "1/1/2015";</para><para>//Save to file</para><para>workbook.SaveToFile("Value.xlsx");</para>
|
|
|
Value2 |
Returns or sets the cell value. Read/write Variant.
The only difference between this property and the Value property is
that the Value2 property doesn't use the Currency and Date data types.
(Inherited from
IXLSRange
.)
The following code illustrates how to access Value2 property of the Range:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Assigning Value2 property of the Range</para><para>worksheet["A1"].Value2 = DateTime.Now;</para><para>worksheet["A3"].Value2 = false;</para><para>//Checking Range types</para><para>Console.WriteLine(worksheet["A1"].HasDateTime);</para><para>Console.WriteLine(worksheet["A3"].HasBoolean);</para>
|
|
|
VerticalAlignment |
Returns or sets the vertical alignment of the specified object.
Read/write VerticalAlignType.
(Inherited from
IXLSRange
.)
The following code illustrates how to set vertical alignment type:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Set text</para><para>worksheet["A1"].Text = "Test";</para><para>//Set alignment</para><para>worksheet["A1"].VerticalAlignment = VerticalAlignType.Top;</para><para>//Save to file</para><para>workbook.SaveToFile("VerticalAlignment.xlsx");</para>
|
|
|
Worksheet |
Returns a Worksheet object that represents the worksheet
containing the specified range. Read-only.
(Inherited from
IXLSRange
.)
|
| Name | Description | |
|---|---|---|
|
|
Activate |
Activates a single cell, scroll to it and activates the corresponding sheet.
To select a range of cells, use the Select method.
(Inherited from
IXLSRange
.)
The following code illustrates how to activate a Range with scroll flag:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Activates 'F1' cell.</para><para>worksheet.Range["F1"].Activate(true);</para><para>//Save to file</para><para>workbook.SaveToFile("Activate.xlsx");</para>
|
|
|
AddComment |
Adds comment to the range.
(Inherited from
IXLSRange
.)
The following code illustrates how to insert Comments in the Range:
<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 comment = worksheet.Range["A1"].AddComment();</para><para>comment.Text= "Comments";</para><para>//Save to file</para><para>workbook.SaveToFile("AddComment.xlsx");</para>
|
|
|
AutoFitColumns |
Autofits all columns in the range.
(Inherited from
IXLSRange
.)
The following code illustrates how to auto-size column width to its cell content:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Auto-fit columns</para><para>worksheet.Range["B4"].Text = "Fit the content to column";</para><para>worksheet.Range["B4"].AutoFitColumns();</para><para>//Save to file</para><para>workbook.SaveToFile("AutoFitRows.xlsx");</para>
|
|
|
AutoFitRows |
Autofits all rows in the range.
(Inherited from
IXLSRange
.)
The following code illustrates how to auto-size row height to its cell content:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Auto-fit rows</para><para>worksheet.Range["A2"].Text = "Fit the content to row";</para><para>worksheet.Range["A2"].IsWrapText = true;</para><para>worksheet.Range["A2"].AutoFitRows();</para><para>//Save to file</para><para>workbook.SaveToFile("AutoFitRows.xlsx");</para>
|
|
|
BorderAround |
Sets around border for current range.
(Inherited from
IXLSRange
.)
The following code illustrates how to apply border around the Range:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Set text</para><para>worksheet["C2"].Text = "Sample";</para><para>worksheet["D2"].Text = "text";</para><para>worksheet["C3"].Text = "in";</para><para>worksheet["D3"].Text = "cell";</para><para>//Set border</para><para>worksheet["C2:D3"].BorderAround();</para><para>//Save to file</para><para>workbook.SaveToFile("BorderAround.xlsx");</para>
|
|
|
BorderAround(LineStyleType) |
Sets around border for current range.
(Inherited from
IXLSRange
.)
The following code illustrates how to apply border around the Range:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Set text</para><para>worksheet["C2"].Text = "Sample";</para><para>worksheet["D2"].Text = "text";</para><para>worksheet["C3"].Text = "in";</para><para>worksheet["D3"].Text = "cell";</para><para>//Set border</para><para>worksheet["C2:D3"].BorderAround(LineStyleType.Thick);</para><para>//Save to file</para><para>workbook.SaveToFile("BorderAround.xlsx");</para>
|
|
|
BorderAround(LineStyleType, ExcelColors) |
Sets around border for current range.
(Inherited from
IXLSRange
.)
The following code illustrates how to apply border around the Range with color from Spire.Xls.ExcelColors structure:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Set text</para><para>worksheet["C2"].Text = "Sample";</para><para>worksheet["D2"].Text = "text";</para><para>worksheet["C3"].Text = "in";</para><para>worksheet["D3"].Text = "cell";</para><para>//Set border</para><para>worksheet["C2:D3"].BorderAround(LineStyleType.Thick , ExcelColors.Red);</para><para>//Save to file</para><para>workbook.SaveToFile("BorderAround.xlsx");</para>
|
|
|
BorderAround(LineStyleType, Color) |
Sets around border for current range.
(Inherited from
IXLSRange
.)
The following code illustrates how to apply border around the Rangewith color from System.Drawing.Color structure:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Set text</para><para>worksheet["C2"].Text = "Sample";</para><para>worksheet["D2"].Text = "text";</para><para>worksheet["C3"].Text = "in";</para><para>worksheet["D3"].Text = "cell";</para><para>//Set border</para><para>worksheet["C2:D3"].BorderAround(LineStyleType.Thick , Color.Red);</para><para>//Save to file</para><para>workbook.SaveToFile("BorderAround.xlsx");</para>
|
|
|
BorderInside |
Sets inside border for current range.
(Inherited from
IXLSRange
.)
The following code illustrates how to apply border inside the Range:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Set text</para><para>worksheet["C2"].Text = "Sample";</para><para>worksheet["D2"].Text = "text";</para><para>worksheet["C3"].Text = "in";</para><para>worksheet["D3"].Text = "cell";</para><para>//Set border</para><para>worksheet["C2:D3"].BorderInside();</para><para>//Save to file</para><para>workbook.SaveToFile("BorderInside.xlsx");</para>
|
|
|
BorderInside(LineStyleType) |
Sets inside border for current range.
(Inherited from
IXLSRange
.)
The following code illustrates how to apply border inside the Range:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Set text</para><para>worksheet["C2"].Text = "Sample";</para><para>worksheet["D2"].Text = "text";</para><para>worksheet["C3"].Text = "in";</para><para>worksheet["D3"].Text = "cell";</para><para>//Set border</para><para>worksheet["C2:D3"].BorderInside(LineStyleType.Thick);</para><para>//Save to file</para><para>workbook.SaveToFile("BorderInside.xlsx");</para>
|
|
|
BorderInside(LineStyleType, ExcelColors) |
Sets inside border for current range.
(Inherited from
IXLSRange
.)
The following code illustrates how to apply border inside the Range with color from Spire.Xls.ExcelColors structure:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Set text</para><para>worksheet["C2"].Text = "Sample";</para><para>worksheet["D2"].Text = "text";</para><para>worksheet["C3"].Text = "in";</para><para>worksheet["D3"].Text = "cell";</para><para>//Set border</para><para>worksheet["C2:D3"].BorderInside(LineStyleType.Thick , ExcelColors.Red);</para><para>//Save to file</para><para>workbook.SaveToFile("BorderInside.xlsx");</para>
|
|
|
BorderInside(LineStyleType, Color) |
Sets inside border for current range.
(Inherited from
IXLSRange
.)
The following code illustrates how to apply border inside the Range with color from System.Drawing.Color structure:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Set text</para><para>worksheet["C2"].Text = "Sample";</para><para>worksheet["D2"].Text = "text";</para><para>worksheet["C3"].Text = "in";</para><para>worksheet["D3"].Text = "cell";</para><para>//Set border</para><para>worksheet["C2:D3"].BorderInside(LineStyleType.Thick , Color.Red);</para><para>//Save to file</para><para>workbook.SaveToFile("BorderInside.xlsx");</para>
|
|
|
BorderNone |
Sets none border for current range.
(Inherited from
IXLSRange
.)
The following code illustrates how to remove borders in the Range:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>workbook.LoadFromFile("Sample.xlsx");</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Remove borders</para><para>worksheet["C2"].BorderNone();</para><para>//Save to file</para><para>workbook.SaveToFile("BorderNone.xlsx");</para>
|
|
|
Clear |
Clears the cell content, formats, comments based on clear option.
(Inherited from
IXLSRange
.)
The following code illustrates how to clear the Range with clear options:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>workbook.LoadFromFile("Sample.xlsx");</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Clears the Range C2 with its clear options</para><para>worksheet.Range["C2"].Clear(ExcelClearOptions.ClearAll);</para><para>//Save to file</para><para>workbook.SaveToFile("ClearContents.xlsx");</para>
|
|
|
ClearContents |
Clear the contents of the Range.
(Inherited from
IXLSRange
.)
The following code illustrates how to clear the Range:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>workbook.LoadFromFile("Sample.xlsx");</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Clears the Range C2</para><para>worksheet.Range["C2"].ClearContents();</para><para>//Save to file</para><para>workbook.SaveToFile("ClearContents.xlsx");</para>
|
|
|
CollapseGroup |
Collapses current group.
(Inherited from
IXLSRange
.)
The following code illustrates how to remove borders in the Range:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>workbook.LoadFromFile("Sample.xlsx");</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Collapse group</para><para>worksheet.Range["A5:A15"].CollapseGroup(GroupByType.ByRows);</para><para>//Save to file</para><para>workbook.SaveToFile("CollapseGroup.xlsx");</para>
|
|
|
ExpandGroup(GroupByType) |
Expands current group.
(Inherited from
IXLSRange
.)
The following code illustrates how to expand the group in the Range:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>workbook.LoadFromFile("Sample.xlsx");</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Expand group with flag set to expand parent</para><para>worksheet.Range["A5:A15"].ExpandGroup(GroupByType.ByRows);</para><para>//Save to file</para><para>workbook.SaveToFile("ExpandGroup.xlsx");</para>
|
|
|
ExpandGroup(GroupByType, ExpandCollapseFlags) |
Expands current group.
(Inherited from
IXLSRange
.)
The following code illustrates how to perform ExpandGroup in the Range with collapse option:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>workbook.LoadFromFile("Sample.xlsx");</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Expand group with flag set to expand parent</para><para>worksheet.Range["A5:A15"].ExpandGroup(GroupByType.ByRows, ExpandCollapseFlags.ExpandParent);</para><para>//Save to file</para><para>workbook.SaveToFile("ExpandGroup.xlsx");</para>
|
|
|
ExportDataTable |
Exports data to a DataTable based on the specified options.
(Inherited from
IXLSRange
.)
|
|
|
FreezePanes |
Freezes pane at the current range.
(Inherited from
IXLSRange
.)
The following code illustrates how to freeze a pane in the Range:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Applying Freeze Pane to the sheet by specifying a cell</para><para>worksheet.Range["B2"].FreezePanes();</para><para>//Save to file</para><para>workbook.SaveToFile("FreezePanes.xlsx");</para>
|
|
|
GetEnumerator |
Returns an enumerator that iterates through a collection.
(Inherited from
IEnumerable
.)
|
|
|
Intersect |
Returns intersection of this range with the specified one.
(Inherited from
IXLSRange
.)
The following code illustrates how to perform intersectwith in the Range:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Get intersect range</para><para>IXLSRange range = worksheet.Range["A16:C16"];</para><para>IXLSRange commonRange = worksheet.Range["B16:D16"].Intersect(range);</para><para>//Save to file</para><para>workbook.SaveToFile("Intersect.xlsx");</para>
|
|
|
Merge |
Creates a merged cell from the specified Range object.
(Inherited from
IXLSRange
.)
The following code illustrates how to merge the Range:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Set text</para><para>worksheet["A1"].Text = "Merged cell";</para><para>//Merge cells</para><para>worksheet["A1:B1"].Merge();</para><para>//Save to file</para><para>workbook.SaveToFile("Merge.xlsx");</para>
|
|
|
Merge(Boolean) |
Creates a merged cell from the specified Range object.
(Inherited from
IXLSRange
.)
The following code illustrates how to merge the Range with clear option:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Set text</para><para>worksheet["A1"].Text = "Merged cell";</para><para>worksheet["B1"].Text = "sample";</para><para>//Merge cells</para><para>worksheet["A1:B1"].Merge(true);</para><para>//Save to file</para><para>workbook.SaveToFile("Merge.xlsx");</para>
|
|
|
Merge(IXLSRange) |
Returns merge of this range with the specified one.
(Inherited from
IXLSRange
.)
The following code illustrates how to check whether two ranges are mergable or not:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Merge range</para><para>worksheet["A2:B2"].Merge();</para><para>//Get mergable range</para><para>IXLSRange mergableRange = worksheet["A2"].MergeArea.Merge(worksheet["C2"]);</para><para>//Check mergable Area</para><para>Console.Write(mergableRange.RangeAddressLocal);</para><para>//Save to file</para><para>workbook.SaveToFile("Intersect.xlsx");</para>
|
|
|
Remove |
Removes range from the collection.
|
|
|
UnMerge |
Separates a merged area into individual cells.
(Inherited from
IXLSRange
.)
The following code illustrates how to UnMerge the merged cells:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Set text</para><para>worksheet["A1"].Text = "Merged cell";</para><para>//Merge cells</para><para>worksheet["A1:B1"].Merge(true);</para><para>//Unmerge cells</para><para>worksheet["A1:B1"].UnMerge();</para><para>//Save to file</para><para>workbook.SaveToFile("UnMerge.xlsx");</para>
|