XlsRange Methods |
The XlsRange type exposes the following members.
| 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
|