[]
Represents the IRange object.
public interface IRange
Gets or sets the property which controls indentation of text when horizontal or vertical alignment is set to distributed.
bool AddIndent { get; set; }
true
if [add indent]; otherwise, false
.
Gets a string value that represents the range reference in the absolute A1 format.
string Address { get; }
For more address formats, use the GetAddress(bool, bool, ReferenceStyle, IRange) method.
Returns an instance of IAreas which represents an array of IRanges where each IRange returned by IAreas represents one cell or range.
IAreas Areas { get; }
The areas.
Gets or sets the cell background image. Supported image types include: PNG, JPG, ICO, SVG, GIF. This would be visible only in SpreadJS and Exporting to PDF/HTML/IMG.
byte[] BackgroundImage { get; set; }
The cell backgroud image. Type is byte[], where byte[] represents image byte array.
Gets or sets the cell background image layout, default is Stretch.
BackgroundImageLayout BackgroundImageLayout { get; set; }
The cell backgroud image layout.
Gets or sets the binding path of the current cell or column. If range is normal range, gets or sets the binding path of the top-left cell of range. If range is EntireColumn, gets or sets the binding path of the left column binding path of range. If range is EntireRow, gets or sets null.
string BindingPath { get; set; }
Returns an instance of IBorders which represents the cell borders of the cell or range represented by this IRange.
IBorders Borders { get; }
The borders.
Gets or sets the cell padding for range. SpreadJS only.
ICellPadding CellPadding { get; set; }
Returns the IRange object that represents the cells in the specified range.
IRange Cells { get; }
Gets or sets the cell type for specified range in the sheet.
BaseCellType CellType { get; set; }
The cell type.
Returns the zero based column number of the first column of the first range.
int Column { get; }
The column.
Returns the column count of the first range.
int ColumnCount { get; }
The column.
Returns the IRange object that represents the columns in the specified range.
IRange Columns { get; }
Gets or sets the width of the individual columns represented in this range in characters.
double ColumnWidth { get; set; }
Gets or sets the width of the individual columns represented in this range in pixels.
double ColumnWidthInPixel { get; set; }
Returns an instance of IComment which may be used to get and set Comment properties of the cells.
IComment Comment { get; }
Returns an instance of ICommentThreaded which may be used to get and set ICommentThreaded properties of the cells.
ICommentThreaded CommentThreaded { get; }
Returns the number of objects in the collection.
int Count { get; }
The object count.
Gets whether the specified cell is part of an array, returns an IRange object that represents the entire array.
IRange CurrentArray { get; }
Gets or sets the default value of the cell, it can be the value data or the formula string. It works when the cell has no data.
object DefaultValue { get; set; }
Gets a DisplayFormat object that represents the display settings for the specified range.
IDisplayFormat DisplayFormat { get; }
Returns a new instance of IRange which represents the same range of cells, but expanded to include all rows.
IRange EntireColumn { get; }
Returns an IRange representing the area of the current IRange which is iteratively grown as needed until it includes no partial merged cells.
IRange EntireMergeArea { get; }
Returns a new instance of IRange which represents the same range of cells, but expanded to include all columns.
IRange EntireRow { get; }
Returns an instance of IFont which may be used to get and set font properties of the cells represented by this IRange.
IFont Font { get; }
The font.
Returns a FormatConditions collection that represents all the conditional formats for the specified range.
IFormatConditions FormatConditions { get; }
Gets or sets the formula of the cells represented by this IRange in A1-style notation.
string Formula { get; set; }
The formula.
Gets or sets the formula of the cells represented by this IRange in A1-style array notation.
string Formula2 { get; set; }
The formula.
Gets or sets the localized formula of the cells represented by this IRange in A1-style array notation.
string Formula2Local { get; set; }
The formula.
Gets or sets the formula of the cells represented by this IRange in R1C1-style array notation.
string Formula2R1C1 { get; set; }
Gets or sets the localized formula in array notation of the cells represented by this IRange in R1C1-style array notation.
string Formula2R1C1Local { get; set; }
Gets or sets the array formula of a range.
string FormulaArray { get; set; }
Gets or sets the array formula of a range, using ReferenceStyle.R1C1.
string FormulaArrayR1C1 { get; set; }
Gets or sets whether the formula will be hidden when the worksheet is protected.
bool FormulaHidden { get; set; }
Gets or sets the localized formula of the cells represented by this IRange in A1-style notation.
string FormulaLocal { get; set; }
The formula.
Gets or sets the formula of the cells represented by this IRange in R1C1-style notation.
string FormulaR1C1 { get; set; }
Gets or sets the localized formula of the cells represented by this IRange in R1C1-style notation.
string FormulaR1C1Local { get; set; }
Determines if the specified cell is part of an array formula.
bool HasArray { get; }
Returns true if the cell or range contains any formulas; otherwise, false is returned.
bool HasFormula { get; }
true
if this instance has formula; otherwise, false
.
Returns true if any of the cells represented by this range have data validation associated with them.
bool HasValidation { get; }
Gets the height, in points, of the range.
double Height { get; }
Gets the height, in pixels, of the range.
double HeightInPixel { get; }
Gets or sets the property which specifies whether rows or columns should be hidden.
bool Hidden { get; set; }
true
if hidden; otherwise, false
.
Gets or sets the HorizontalAlignment of a cell or range.
HorizontalAlignment HorizontalAlignment { get; set; }
The horizontal alignment.
Returns an instance of IHyperLinks which may be used to get and set HyperLinks properties.
IHyperlinks Hyperlinks { get; }
Gets or sets the error type of the range to be ignored.
IgnoredErrorType IgnoredError { get; set; }
Gets or sets the indent level of the specified cell(s).
int IndentLevel { get; set; }
The indent level.
Returns the IInterior which represents the interior (background) color and pattern of the specified cell(s).
IInterior Interior { get; }
The interior.
Indicates whether the cell string value is a rich text.
bool IsRichText { get; }
Returns a new instance of IRange which is offset from this IRange.
IRange this[int rowOffset, int columnOffset] { get; }
rowOffset
intThe row offset.
columnOffset
intThe column offset.
IRange.
Returns a new instance of IRange by index which represents a cell.
IRange this[int index] { get; }
index
intThe index of range.
IRange.
Gets or sets the setting for watermark. SpreadJS only.
ILabelOptions LabelOptions { get; }
Returns the zero based column number of the last column of the first range.
int LastColumn { get; }
The column.
Returns the zero based row number of the last row of the first range.
int LastRow { get; }
The row.
Gets or sets the property which specifies whether cells should be locked.
bool Locked { get; set; }
true
if locked; otherwise, false
.
Returns an IRange representing the merged range containing the specified cell. If the specified cell isn't in a merged range, this property returns the specified cell.
IRange MergeArea { get; }
Gets or sets the property which specifies whether cells are merged.
bool MergeCells { get; set; }
Gets or sets the number format of the cells in the range.
string NumberFormat { get; set; }
Gets or sets the text orientation of a cell or range, which may be from -90 to 90 degrees, or 255(vertical text).
int Orientation { get; set; }
The orientation.
Gets or sets the current outline level of the specified row or column.
int OutlineLevel { get; set; }
Gets or sets the reading order for the specified object.
ReadingOrder ReadingOrder { get; set; }
Gets the rich text object associate with the top-left cell of this range.
IRichText RichText { get; }
Returns the zero based row number of the first row of the first range.
int Row { get; }
The row.
Returns the row count of the first range.
int RowCount { get; }
The row.
Gets or sets the height of the individual rows represented by this range in points.
double RowHeight { get; set; }
Gets or sets the height of the individual rows represented by this range in pixels.
double RowHeightInPixel { get; set; }
Returns the IRange object that represents the rows in the specified range.
IRange Rows { get; }
Gets or sets whether to show the detail (Returns True if the outline is expanded for the specified range, so that the detail of the column or row is visible). The specified range must be a single summary column or row in an outline (read or write).
bool ShowDetail { get; set; }
The following statements are true: 1.The range must be in a single summary row or column. 2.This property returns False if any of the children of the row or column are hidden. 3.Setting this property to True is equivalent to unhiding all the children of the summary row or column. 4.Setting this property to False is equivalent to hiding all the children of the summary row or column.
Gets or sets the property which specifies whether cells will be drawn in a smaller font if needed to display the contents of the cell.
bool ShrinkToFit { get; set; }
true
if [shrink to fit]; otherwise, false
.
Returns an instance of ISparklineGroups which may be used to get and set SparklineGroups properties of the cells
ISparklineGroups SparklineGroups { get; }
Gets or sets the named style IStyle associated with the cells represented by this IRange.
IStyle Style { get; set; }
The style.
Determines if the range is an outlining summary row or column.
bool Summary { get; }
Gets or sets the tag value for specified range in the sheet. SpreadJS only.
object Tag { get; set; }
The tag value.
Gets the value of the cell represented by this IRange as a formatted string.
string Text { get; }
The text.
Returns an IRange representing the used range in the current range.
IRange UsedRange { get; }
Determines if the row height of the IRange object equals the standard height of the sheet.
bool UseStandardHeight { get; set; }
Determines if the column width of the IRange object equals the standard width of the sheet.
bool UseStandardWidth { get; set; }
Returns an instance of IValidation which may be used to get and set validation properties of the cells represented by this IRange.
IValidation Validation { get; }
Returns true if the validation options of all cells represented by this IRange are the same; otherwise, false is returned.
bool ValidationIsSame { get; }
Gets the value of the specified range as a string, double, bool, object[,] (Object(,) in Visual Basic) or null (Nothing in Visual Basic); or sets the value of the specified cell as a string, double, System.Int16, int, long, bool, System.DateTime, System.TimeSpan, object[,] (Object(,) in Visual Basic) or null (Nothing in Visual Basic).
object Value { get; set; }
The value.
Gets or sets the VerticalAlignment of a cell or range.
VerticalAlignment VerticalAlignment { get; set; }
The vertical alignment.
Gets or sets the watermark for range. SpreadJS only.
string Watermark { get; set; }
Gets the width, in points, of the range.
double Width { get; }
Gets the width, in pixels, of the range.
double WidthInPixel { get; }
Returns the parent Worksheet of this range.
IWorksheet Worksheet { get; }
The worksheet.
Get or sets the flag which indicates whether word wrap is enabled in a cell.
bool WrapText { get; set; }
true
if [wrap text]; otherwise, false
.
Activates a single cell, which must be inside the current selection.
void Activate()
Adds comments to the current IRange.
IComment AddComment(string text)
text
stringThe text you want to add.
Adds a threaded comment to the current IRange.
ICommentThreaded AddCommentThreaded(string text, string author = null)
text
stringThe text you want to add.
author
stringThe name of the author.
The newly added threaded comment.
Filters a list using the AutoFilter.
void AutoFilter(bool isFirstRowData, int field = 0, object criteria1 = null, AutoFilterOperator op = AutoFilterOperator.And, object criteria2 = null, bool visibleDropDown = true)
isFirstRowData
boolIndicates whether the first row of the selection area participates in filtering. When set to true, the behavior is consistent with SpreadJS; when false, it is consistent with Microsoft Excel.
field
intOptional Object. The integer offset of the field on which you want to base the filter (from the left of the list; the leftmost field is field zero).
criteria1
objectOptional Object. The criteria (a string; for example, "101"). Use "=" to find blank fields, or use "<>" to find nonblank fields. If this argument is omitted, the criteria is All. If Operator is xlTop10Items, Criteria1 specifies the number of items (for example, "10").
op
AutoFilterOperatorOptional AutoFilterOperator.
criteria2
objectOptional Object. The second criteria (a string). Used with Criteria1 and Operator to construct compound criteria.
visibleDropDown
boolOptional Object. True to display the AutoFilter drop-down arrow for the filtered field; False to hide the AutoFilter drop-down arrow for the filtered field. True by default.
Filters a list using the AutoFilter.
void AutoFilter(int field = 0, object criteria1 = null, AutoFilterOperator op = AutoFilterOperator.And, object criteria2 = null, bool visibleDropDown = true)
field
intOptional Object. The integer offset of the field on which you want to base the filter (from the left of the list; the leftmost field is field zero).
criteria1
objectOptional Object. The criteria (a string; for example, "101"). Use "=" to find blank fields, or use "<>" to find nonblank fields. If this argument is omitted, the criteria is All. If Operator is xlTop10Items, Criteria1 specifies the number of items (for example, "10").
op
AutoFilterOperatorOptional AutoFilterOperator.
criteria2
objectOptional Object. The second criteria (a string). Used with Criteria1 and Operator to construct compound criteria.
visibleDropDown
boolOptional Object. True to display the AutoFilter drop-down arrow for the filtered field; False to hide the AutoFilter drop-down arrow for the filtered field. True by default.
Changes the width of the columns in the range or the height of the rows in the range to achieve the best fit.
void AutoFit()
Changes the width of the columns in the range or the height of the rows in the range to achieve the best fit.
considerMergedCell
Indicates whether to consider merged cells in a single row.
void AutoFit(bool considerMergedCell)
considerMergedCell
boolCalculates formulas of the range as needed.
void Calculate()
Returns a ITextRun object that represents a range of characters within the cell text, this method can only be called when the value of cell is a string, or else System.InvalidOperationException is thrown.
ITextRun Characters(int startIndex, int length)
startIndex
intthe start index of characters in whole cell text.
length
intthe length of characters.
Clears formulas, values, and all formatting from the current IRange.
void Clear()
Clears the comments from the current IRange.
void ClearComments()
Clears the threaded comment from the current IRange.
void ClearCommentsThreaded()
Clears formulas and values from the current IRange.
void ClearContents()
Clears all formatting from the current IRange.
void ClearFormats()
Clears all hyperLinks from the current IRange.
void ClearHyperlinks()
Clears the outline for the specified range.
void ClearOutline()
Copies the range to the specified range.
void Copy(IRange destination, PasteOption pasteOption)
destination
IRangeSpecifies the new range to which the specified range will be pasted. It can be the range of the same or another workbook.
pasteOption
PasteOptionSpecifies the part of the range to be pasted and whether to include hidden range.
Copies the range to the specified range.
[Obsolete("Please use the PasteOption overload instead.")]
void Copy(IRange destination, PasteType pasteType = PasteType.Default)
destination
IRangeSpecifies the new range to which the specified range will be pasted. It can be the range of the same or another workbook.
pasteType
PasteTypeSpecifies the part of the range to be pasted.
Copies the range to the specified range.
void Copy(IRange destination)
destination
IRangeSpecifies the new range to which the specified range will be pasted. It can be the range of the same or another workbook.
Cuts the range to the specified range.
void Cut(IRange destination)
destination
IRangeSpecifies the new range to which the specified range will be pasted. It can be the range of the same or another workbook.
Deletes a cell or a range of cells from the worksheet and shifts other cells to replace deleted cells.
Specifies which way to shift the cells.void Delete(DeleteShiftDirection shiftDirection = DeleteShiftDirection.Auto)
shiftDirection
DeleteShiftDirectionDesignates all the formulas of the range to be recalculated when the next calculation occurs.
void Dirty()
Finds specific information in a range.
IRange Find(object what, IRange after = null, FindOptions options = null)
what
objectThe data to search for. Can be a string, double, System.DateTime, System.TimeSpan, bool or int.
after
IRangeThe cell after which you want the search to begin. This corresponds to the position of the active cell when a search is done from the user interface. Notice that After must be a single cell in the range. Remember that the search begins after this cell; the specified cell isn't searched unless your code wraps back around to this cell. If you do not specify this argument, the search starts at the cell in the upper-left corner of the range when SearchDirection is Next, or at the cell in the bottom-right corner of the range when SearchDirection is Previous.
options
FindOptionsThe find options.
Generates the range data from the JSON string.
void FromJson(string json)
json
stringthe JSON string that contains range info.
Generate the corresponding function "GETPIVOTDATA" for the cells in the pivot table.
string GenerateGetPivotDataFunction(IRange destination = null)
destination
IRangeIndicates for which area the "GETPIVOTDATA" function is generated.
"GETPIVOTDATA" function
Returns a string value that represents the range reference. If all parameters are omitted, the return value is equal to the Address property.
string GetAddress(bool rowAbsolute = true, bool columnAbsolute = true, ReferenceStyle referenceStyle = ReferenceStyle.A1, IRange relativeTo = null)
rowAbsolute
boolTrue to return the row part of the reference as an absolute reference.
columnAbsolute
boolTrue to return the column part of the reference as an absolute reference.
referenceStyle
ReferenceStyleThe reference style.
relativeTo
IRangeIf RowAbsolute and ColumnAbsolute are False, and ReferenceStyle is R1C1, defines a starting point for the relative reference. The default reference is $A$1.
Gets the dependent ranges of the left top cell of the range.
IReadOnlyList<IRange> GetDependents()
The dependent ranges.
Gets the dependent ranges of all the cells of the range.
IReadOnlyList<IRange> GetDependents(bool includeIndirect)
includeIndirect
boolInclude the indirect dependent cells.
The dependent ranges.
Gets the precedent ranges of the left top cell of the range.
IReadOnlyList<IRange> GetPrecedents()
The precedent ranges.
Gets the precedent ranges of all the cells of the range.
IReadOnlyList<IRange> GetPrecedents(bool includeIndirect)
includeIndirect
boolInclude the indirect precedent cells.
The precedent ranges.
Gets an IRange representing the used range in the current range.
IRange GetUsedRange(UsedRangeType type = UsedRangeType.All)
type
UsedRangeTypeThe feature type.
Attempts to achieve the specified goal, from the calculated result of the formula in the cell represented by this IRange, by modifying the specified changingCell. If you know the result that you want from a formula, but are not sure what input value the formula needs to get that result, use the Goal Seek feature.
bool GoalSeek(double goal, IRange changingCell)
goal
doubleSpecifies the desired goal value.
changingCell
IRangeSpecifies the cell to change.
True if the desired result value is successfully found, otherwise False.
Increments the OutlineLevel of the specified rows or columns.
void Group()
Inserts a cell or a range of cells into the worksheet and shifts other cells away to make space.
Specifies which way to shift the cells.void Insert(InsertShiftDirection shiftDirection = InsertShiftDirection.Auto)
shiftDirection
InsertShiftDirectionReturns an IRange object that represents the intersection of two ranges.
If range2 is from a different worksheet, an exception is thrown.
IRange Intersect(IRange range2)
range2
IRangeThe range to intersect with this range.
A new range which consists of the intersection of this range and range2, or null if the ranges do not intersect.
Returns an IRange object that represents the intersection of several ranges.
If one or more ranges from a different worksheet are specified, an exception is thrown.
IRange Intersect(params IRange[] ranges)
ranges
IRange[]The intersecting ranges.
A new range which consists of the intersection of this range and other ranges, or null if the ranges do not intersect.
Merges the cells in the represented range into a single merged cell.
void Merge(bool isAcross = false)
isAcross
boolOptional Object. True to merge cells in each row of the specified range as separate merged cells. The default value is False.
Returns an IRange object that represents the offset of this range.
IRange Offset(int rowOffset, int columnOffset)
rowOffset
intRow offset.
columnOffset
intColumn offset.
A new range which consists of the offset of this range.
Removes subtotals from a list.
void RemoveSubtotal()
Search in formulas and replace. Using this method doesn't change either the selection or the active cell.
int Replace(object what, object replacement, ReplaceOptions options = null)
what
objectThe string you want to search for.
replacement
objectThe replacement string.
options
ReplaceOptionsThe replace options.
Number of cells that was replaced.
Selects the object.
void Select()
void Sort(IRange key, SortOrder order = SortOrder.Ascending, SortOrientation orientation = SortOrientation.Columns, bool caseSensitive = false)
key
IRangeorder
SortOrderorientation
SortOrientationcaseSensitive
boolSorts the cells represented by this range according to the specified options.
void Sort(SortOrientation orientation = SortOrientation.Columns, bool caseSensitive = false, params IValueSortField[] keys)
orientation
SortOrientationThe orientation.
caseSensitive
boolif set to true
[case sensitive].
keys
IValueSortField[]The SortFieldBase array.
Gets a IRange object that represents all the cells that match the specified type and value.
IRange SpecialCells(SpecialCellType type, SpecialCellsValue? value = null)
type
SpecialCellTypeThe cells to include.
value
SpecialCellsValue?If Type is either Constants or Formulas, this argument is used to determine which types of cells to include in the result. These values can be added together to return more than one type. The default is to select all constants or formulas, no matter what the type.
Returns a IRange object that represents all the cells that match the specified type and value.
Creates subtotals for the range.
void Subtotal(int groupBy, ConsolidationFunction subtotalFunction, IEnumerable<int> totalList, bool replace = true, bool pageBreaks = false, SummaryRow summaryRowLocation = SummaryRow.Below)
groupBy
intThe field to group by, as a one-based integer offset.
subtotalFunction
ConsolidationFunctionThe subtotal function.
totalList
System.Collections.Generic.IEnumerable<T><int>An array of 1-based field offsets, indicating the fields to which the subtotals are added.
replace
boolTrue to replace existing subtotals. The default value is True.
pageBreaks
boolTrue to add page breaks after each group. The default value is False.
summaryRowLocation
SummaryRowPlaces the summary data relative to the subtotal.
Saves the range to the specified image stream using options.
void ToImage(Stream stream, ImageType imageType, ImageSaveOptions options)
stream
System.IO.StreamThe output image stream.
imageType
ImageTypeSpecifies the type of image to create.
options
ImageSaveOptionsThe options for output image.
Saves the range to the specified image stream.
void ToImage(Stream stream, ImageType imageType)
stream
System.IO.StreamThe output image stream.
imageType
ImageTypeSpecifies the type of image to create.
Saves the range to the specified image file using options.
void ToImage(string imageFile, ImageSaveOptions options)
imageFile
stringThe output image file.
options
ImageSaveOptionsThe options for output image.
Saves the range to the specified image file.
void ToImage(string imageFile)
imageFile
stringThe output image file.
Generates a JSON string from the range.
string ToJson()
the JSON string that contains range info.
Decrements the OutlineLevel of the specified rows or columns.
void Ungroup()
Returns an IRange object that represents the union of two ranges.
If range2 is from a different worksheet, an exception is thrown.
IRange Union(IRange range2)
range2
IRangeThe range to union with this range.
A new range which consists of the union of this range and range2.
Returns an IRange object that represents the union of several ranges.
If one or more ranges from a different worksheet are specified, an exception is thrown.
IRange Union(params IRange[] ranges)
ranges
IRange[]Other ranges to union with this range.
A new range which consists of the union of this range and other ranges.
Converts merged cells in the represented range to normal cells.
void UnMerge()