XlsRange Class |
Namespace: Spire.Xls.Core.Spreadsheet
The XlsRange type exposes the following members.
Name | Description | |
---|---|---|
![]() ![]() |
BooleanValue |
Returns or sets the bool value of the specified range.
![]()
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).
|
![]() ![]() |
BuiltInStyle |
Gets/sets built in style.
![]()
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.
|
![]() |
Cells |
Obsolete.
Returns a Range object that represents the cells in the specified range.
|
![]() |
CellsCount |
Gets number of cells.
|
![]() ![]() |
CellStyleName |
Gets/sets name of the style for the current range.
![]()
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.
![]()
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 specified column</para><para>int firstColumn = worksheet["E1:R3"].Column;</para>
|
![]() |
ColumnCount |
Gets number of columns.
|
![]() |
ColumnGroupLevel |
Column group level.
|
![]() |
Columns |
For a Range object, it returns an array of Range objects that represent the
columns in the specified range.
|
![]() ![]() |
ColumnWidth |
Returns or sets the width of all columns in the specified range.
![]()
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>
|
![]() |
CombinedAddress |
Returns the combined range reference in the language.
Read-only String.
|
![]() |
CombinedCells |
Gets the list of combined cells.
|
![]() |
Comment |
Returns a Comment object that represents the comment associated with the cell in the upper-left corner of the range.
|
![]() |
ConditionalFormats |
Obsolete.
Collection of conditional formats for the range.
|
![]() |
Count |
Returns the number of objects in the collection.
|
![]() |
CurrentRegion |
Get the range associated with a range.
|
![]() ![]() |
DataValidation |
Get dataValidation of the sheet. Read Only.
![]()
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 value of the range.
![]()
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>
|
![]() |
DisplayedText |
Gets cell displayed text.
|
![]() |
EndCell |
Returns a Range object that represents the cell at the end of the
region that contains the source range.
|
![]() |
EntireColumn |
Returns a Range object that represents the entire column (or
columns) that contains the specified range.
|
![]() |
EntireRow |
Returns a Range object that represents the entire row (or
rows) that contains the specified range. Read-only.
|
![]() ![]() |
EnvalutedValue |
Returns the calculated value of a formula.
![]()
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 or sets error value of this range.
|
![]() |
ExtendedFormatIndex |
Sets / gets index of extended format.
|
![]() |
FirstColumn |
Gets or sets the index of the first column in the range.
|
![]() |
FirstRow |
Gets or sets the first row of the range.
|
![]() |
Formula |
Returns or sets the object's formula in A1-style notation and in
the language of the macro.
|
![]() ![]() |
FormulaArray |
Returns or sets the array formula of a range.
![]()
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 for the object, using R1C1-style notation in the language of the macro
|
![]() |
FormulaBoolValue |
Gets or sets bool value of the formula.
|
![]() |
FormulaDateTime |
Gets or sets bool value of the formula.
|
![]() |
FormulaErrorValue |
Gets or sets error value of the formula.
|
![]() |
FormulaNumberValue |
Gets or sets double value of the formula.
|
![]() |
FormulaR1C1 |
Returns or sets the formula for the object, using R1C1-style notation in the language of the macro
|
![]() |
FormulaStringValue |
Gets or sets string value of the range.
|
![]() |
FormulaValue |
Gets formula value.
|
![]() ![]() |
HasBoolean |
Indicates whether range contains bool value.
![]()
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>
|
![]() |
HasComment |
Gets a value indicating whether the cell has a comment.
|
![]() |
HasConditionFormats |
Indicates whether each cell of the range has some conditional formatting.
|
![]() |
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.
|
![]() ![]() |
HasDateTime |
Determines if all cells in the range contain datetime.
![]()
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.
|
![]() |
HasExternalFormula |
Check if the formula in the range has external links. Read-only.
|
![]() |
HasFormula |
True if all cells in the range contain formulas;
|
![]() |
HasFormulaArray |
Determines if all cells in the range contain array-entered formula.
|
![]() |
HasFormulaBoolValue |
Determines if all cells in the range contain formula bool value..
|
![]() |
HasFormulaDateTime |
Indicates if current range has formula value formatted as DateTime. Read-only.
|
![]() |
HasFormulaErrorValue |
Determines if all cells in the range contain error value.
|
![]() |
HasFormulaNumberValue |
Indicates whether current range has formula number value.
|
![]() |
HasFormulaStringValue |
Indicates whether current range contains formula value which evaluated as string.
|
![]() ![]() |
HasMerged |
Indicates whether this range is part of merged range.
![]()
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 |
Determines if any one cell in the range contain number.
![]()
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>
|
![]() |
HasPictures |
Indicates whether the range is blank.
|
![]() ![]() |
HasRichText |
Determines if all cells in the range contain rich text string.
![]()
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 |
Determines if all cells in the range contain string.
|
![]() ![]() |
HasStyle |
Determines if all cells in the range containdiffers from default style.
![]()
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.
![]()
The following code illustrates how to set and access HasStyle 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 = "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.
|
![]() |
Hyperlinks |
Returns hyperlinks for this range.
|
![]() |
IgnoreErrorOptions |
Represents ignore error options. If not single cell returs concatenateed flags.
|
![]() ![]() |
IndentLevel |
Returns or sets the indent level for the cell or range. value should be 0 between 15.
![]()
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>
|
![]() |
IsAllNumber |
Determines if all cells in the range contain number.
|
![]() |
IsBlank |
Indicates whether the range is blank.
|
![]() |
IsFormulaHidden |
Determines if the formula will be hidden when the worksheet is protected.
|
![]() |
IsGroupedByColumn |
Indicates whether this range is grouped by column.
|
![]() |
IsGroupedByRow |
Indicates whether this range is grouped by row.
|
![]() |
IsInitialized |
Indicates whether range has been initialized.
|
![]() |
IsSingleCell |
Checks if the current selection is a single cell.
|
![]() |
IsStringsPreserved |
Indicates whether all values in the range are preserved as strings.
|
![]() ![]() |
IsWrapText |
Determines if Microsoft Excel wraps the text in the object.
![]()
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 |
Gets cell range. Read-only.
|
![]() |
Item Int32, Int32 |
Gets / sets cell by row and column index. Row and column indexes are one-based.
|
![]() |
Item String, Boolean |
Gets cell range. Read-only.
|
![]() |
Item Int32, Int32, Int32, Int32 |
Get cell range. Row and column indexes are one-based. Read-only.
|
![]() |
LastColumn |
Gets or sets last column of the range.
|
![]() |
LastRow |
Gets or sets last row of the range.
|
![]() |
MergeArea |
Returns a Range object that represents the merged range containing the specified cell.
|
![]() ![]() |
NumberFormat |
Returns or sets the format code for the object.
![]()
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 text for number format.
![]()
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 or sets number value of the range.
|
![]() |
Parent |
Parent object for this object.
|
![]() ![]() |
RangeAddress |
Returns the range reference in the language of the macro.
Read-only String.
![]()
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.
![]()
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 the range reference in the language of the macro.
![]()
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>
|
![]() |
RangeGlobalAddress2007 |
Gets address global in the format required by Excel 2007.
|
![]() |
RangeGlobalAddressWithoutSheetName |
Return global address without worksheet name.
|
![]() ![]() |
RangeR1C1Address |
Returns the range reference using R1C1 notation.
![]()
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.
![]()
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>
|
![]() |
ReferenceCount |
Get quantity of instance references.
(Inherited from
XlsObject
.)
|
![]() |
RichText |
Returns a RichTextString object that represents the rich text style.
|
![]() |
Row |
Returns the number of the first row of the first area in the range.
|
![]() |
RowCount |
Gets number of rows.
|
![]() |
RowGroupLevel |
Row group level.
|
![]() ![]() |
RowHeight |
Returns the height of all the rows in the range specified, measured in points.
![]()
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, it returns an array of Range objects that represent the
rows in the specified range.
|
![]() |
Style |
Returns a Style object that represents the style of the specified range.
|
![]() |
Text |
Gets / sets text of range.
|
![]() |
TimeSpanValue |
Gets or sets timespan value of cell.
|
![]() ![]() |
Value |
Returns or sets the value of the specified range.
![]()
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.
It's not use for current and datetime types.
![]()
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.
![]()
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>
|
![]() |
Workbook |
Gets the workbook .
|
![]() |
Worksheet |
Returns a worksheet object that represents the worksheet
containing the specified range.
|
![]() |
WorksheetName |
Returns name of the parent worksheet.
|
Name | Description | |
---|---|---|
![]() |
Activate |
Active single cell in the worksheet
|
![]() ![]() |
Activate(Boolean) |
Activates a single cell, scroll to it and activates the corresponding sheet.
To select a range of cells, use the Select method.
![]()
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>
|
![]() |
AddCombinedRange |
Adds a combined range to the collection if it is not already present.
|
![]() |
AddComment |
Adds a comment to the range.
|
![]() |
AddComment(Boolean) |
Adds a comment to the range.
|
![]() |
AddComment(ICommentShape) |
Adds a comment to the shape.
|
![]() |
AddReference |
Increase the quantity of reference. User must use this method when
new wrapper on object is created or reference on object stored.
(Inherited from
XlsObject
.)
|
![]() |
ApplyStyle |
Applies the specified style to the cells within the range, based on the given flag.
|
![]() ![]() |
AutoFitColumns |
Changes the width of the columns in the range in the range to achieve the best fit.
![]()
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 |
Changes the width of the height of the rows in the range to achieve the best fit.
![]()
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.
![]()
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.
![]()
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.
![]()
The following code illustrates how to apply border around the Rangewith 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.
![]()
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.
![]()
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.
![]()
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.
![]()
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.
![]()
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.
![]()
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>
|
![]() |
CalculateAllValue |
Caculate all formula for the specified range
|
![]() |
CheckDisposed |
Checks whether object was disposed and throws exception if it was.
(Inherited from
XlsObject
.)
|
![]() |
CheckRange |
Checks if the given row and column indices are within the valid range of the book.
Throws an ArgumentOutOfRangeException if the indices are out of range.
|
![]() |
Clear(Boolean) |
Clears the cells in the specified range and optionally resets the cell style to "Normal".
|
![]() ![]() |
Clear(ExcelClearOptions) |
Clears the cell based on clear options.
![]()
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>
|
![]() |
ClearAll |
Clears the entire object.
|
![]() |
ClearConditionalFormats |
Clears conditional formats.
|
![]() ![]() |
ClearContents |
Clear the contents of the Range.
![]()
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>
|
![]() |
Clone |
Clones current IXLSRange.
|
![]() ![]() |
CollapseGroup |
Collapses current group.
![]()
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>
|
![]() |
ConvertToNumber |
Convert number that stored as text to number
|
![]() |
CopyToClipboard |
Obsolete.
Copies range to the clipboard.
|
![]() |
Dispose |
This method is called when disposing the object.
|
![]() |
Equals |
Determines whether the specified object is equal to the current object.
(Inherited from
Object
.)
|
![]() ![]() |
ExpandGroup(GroupByType) |
Expands current group.
![]()
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.
![]()
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 the data from the worksheet to a DataTable based on the provided options.
|
![]() |
Finalize |
Destructor. Call dispose method of current object.
(Inherited from
XlsObject
.)
|
![]() |
FindAll(Boolean) |
Finds all cell ranges that match the specified value within the CellRange.
|
![]() |
FindAll(DateTime) |
Finds all occurrences of the specified DateTime value within the CellRange.
|
![]() |
FindAll(TimeSpan) |
Finds all occurrences of the specified TimeSpan value within the CellRange.
|
![]() |
FindAll(Double, FindType) |
Finds all occurrences of the specified value within the CellRange.
|
![]() |
FindAll(String, FindType) |
Finds all occurrences of the specified value within the CellRange.
|
![]() |
FindAll(String, FindType, ExcelFindOptions) |
Finds all occurrences of a specified value within the CellRange.
|
![]() |
FindFirst(Boolean) |
Finds the first cell range that matches the specified value within the CellRange.
|
![]() |
FindFirst(DateTime) |
Searches for the first occurrence of a DateTime value within the specified area of the CellRange.
|
![]() |
FindFirst(TimeSpan) |
Finds the first occurrence of a specified TimeSpan value in the worksheet within the current area.
|
![]() |
FindFirst(Double, FindType) |
Finds the first occurrence of a specified value in the worksheet within the current area.
|
![]() |
FindFirst(String, FindType) |
Finds the first occurrence of a specified string value in the worksheet within the current area.
|
![]() |
FindParent(Type) |
This method is used to find parent with specific type.
(Inherited from
XlsObject
.)
|
![]() |
FindParent( Type ) |
Find parent of object.
(Inherited from
XlsObject
.)
|
![]() |
FindParent(Type, Boolean) |
This method is used to find parent with specific type.
(Inherited from
XlsObject
.)
|
![]() |
FindParents |
Finds parent objects.
(Inherited from
XlsObject
.)
|
![]() |
FindWorksheet |
Finds the worksheet by the given sheet name.
|
![]() ![]() |
FreezePanes |
Freezes panes at the current range in the worksheet. current range should be single cell range.
![]()
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>
|
![]() |
GetConditionFormatsStyle |
Get the calculated condition format style of current Range.
If style of every cell is not same, return null.
If current range without condition format, return null.
|
![]() |
GetEnumerator |
Returns an enumerator that iterates through the collection of IXLSRange objects.
|
![]() |
GetHashCode |
Serves as the default hash function.
(Inherited from
Object
.)
|
![]() |
GetNamedRange |
Get the named range object of current Range.
|
![]() |
GetNewRangeLocation |
Gets new range location.
|
![]() |
GetRectangles |
Gets rectangle information of current range.
|
![]() |
GetRectanglesCount |
Returns number of rectangles..
|
![]() |
GetType |
Gets the
Type
of the current instance.
(Inherited from
Object
.)
|
![]() |
GroupByColumns |
Groups columns.
|
![]() |
GroupByRows |
Groups row.
|
![]() |
InfillCells |
Infills cells based on the current range and updates the internal state.
|
![]() |
InsertOrUpdateCellImage(Stream, Boolean) |
Adds CellImage from the specified file.
this method only support WPS
|
![]() |
InsertOrUpdateCellImage(String, Boolean) |
Adds CellImage from the specified file.
this method only support WPS
|
![]() ![]() |
Intersect |
Returns intersection of this range with the specified one.
![]()
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>
|
![]() |
IsIntersect |
Determines if the current range intersects with the specified range.
|
![]() |
MeasureString |
Measures size of the string.
|
![]() |
MemberwiseClone |
Creates a shallow copy of the current
Object
.
(Inherited from
Object
.)
|
![]() ![]() |
Merge |
Creates a merged cell from the specified Range object.
![]()
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.
![]()
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) |
Creates a merged cell from the specified Range object.
|
![]() |
MoveTo(IXLSRange) |
Moves the range to the specified destination with the default copy options.
|
![]() |
MoveTo(IXLSRange, Boolean) |
Moves the range to the specified destination.
|
![]() |
OnDispose |
Method which can be overriden by users to take any specific actions when
object is disposed.
(Inherited from
XlsObject
.)
|
![]() |
PartialClear |
Partially clear range.
|
![]() |
ReleaseReference |
Decrease quantity of Reference. User must call this method
when freeing resources.
(Inherited from
XlsObject
.)
|
![]() |
RemoveCellImage |
Remove CellImage.
|
![]() |
RemoveCombinedRange |
Removes a combined range from the list of combined ranges and refreshes the combined cells.
|
![]() |
RemoveMergeComment |
Removes merge comments from a cell range.
|
![]() |
ReparseFormulaString |
Reparses formula.
|
![]() |
Replace(String, DateTime) |
Replaces cells' values with new data.
|
![]() |
Replace(String, Double) |
Replaces cells' values with new data.
|
![]() |
Replace(String, String) |
Replaces cells' values with new data.
|
![]() |
Replace(String, DataColumn, Boolean) |
Replaces cells' values with new data.
|
![]() |
Replace(String, DataTable, Boolean) |
Replaces cells' values with new data.
|
![]() |
Replace(String, Double , Boolean) |
Replaces cells' values with new data.
|
![]() |
Replace(String, Int32 , Boolean) |
Replaces cells' values with new data.
|
![]() |
Replace(String, String , Boolean) |
Replaces cells' values with new data.
|
![]() |
SetAutoFormat(AutoFormatType) |
Obsolete.
Sets auto format for current range.
|
![]() |
SetAutoFormat(AutoFormatType, AutoFormatOptions) |
Obsolete.
Sets auto format for current range.
|
![]() |
SetBorderToSingleCell |
Sets the border for a single cell.
|
![]() |
SetDataValidation |
Sets data validation for the range.
|
![]() |
SetExtendedFormatIndex |
Sets index of extended format that defines style for this range..
|
![]() |
SetParent |
Sets parent of the object.
(Inherited from
XlsObject
.)
|
![]() |
SetRowHeight |
Sets row height.
|
![]() |
SetSharedFormula |
Sets the shared formula for a cell or a range of cells.
|
![]() |
TextPartReplace |
Replaces cell's part text and reserve text's format.
|
![]() |
ToString |
Returns a string that represents the current object.
(Inherited from
Object
.)
|
![]() |
UngroupByColumns |
Ungroups column.
|
![]() |
UngroupByRows |
Ungroups row.
|
![]() |
Union |
Combines the current range with another cell range.
|
![]() ![]() |
UnMerge |
Separates a merged area into individual cells.
![]()
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>
|
![]() |
UpdateRange |
Update region of range
|
Name | Description | |
---|---|---|
![]() ![]() |
DEF_MAX_HEIGHT |
Default maximum height value.
|
![]() |
m_bIsDisposed |
Flag which indicates if the object was disposed or not.
(Inherited from
XlsObject
.)
|
![]() |
m_book |
Represents the workbook object.
|
![]() |
m_iBottomRow |
Index of the bottom row.
|
![]() |
m_iLeftColumn |
Index of the left column.
|
![]() |
m_iRightColumn |
Index of the right column.
|
![]() |
m_iTopRow |
Index of the top row.
|
![]() |
m_style |
The base style for the cell.
|