Class RangesCollection
Summary description for RangesCollection.
Implements
Inherited Members
Namespace: Syncfusion.XlsIO.Implementation.Collections
Assembly: Syncfusion.XlsIO.Portable.dll
Syntax
public class RangesCollection : CollectionBaseEx<IRange>, IList<IRange>, ICollection<IRange>, ICloneParent, IRanges, ICombinedRange, IRange, IParentApplication, IEnumerable<IRange>, IEnumerable, INativePTG
Constructors
RangesCollection(IApplication, Object)
Creates new instance of RangesCollection.
Declaration
public RangesCollection(IApplication application, object parent)
Parameters
Type | Name | Description |
---|---|---|
IApplication | application | Application object. |
System.Object | parent | Parent object. |
Properties
Address
Returns the range reference in the language of the macro. Read-only String.
Declaration
public string Address { get; }
Property Value
Type |
---|
System.String |
AddressGlobal
Returns the range reference in the language of the macro. Read-only String.
Declaration
public string AddressGlobal { get; }
Property Value
Type |
---|
System.String |
AddressGlobal2007
Gets address global in the format required by Excel 2007.
Declaration
public string AddressGlobal2007 { get; }
Property Value
Type |
---|
System.String |
AddressLocal
Returns the range reference for the specified range in the language of the user. Read-only String.
Declaration
public string AddressLocal { get; }
Property Value
Type |
---|
System.String |
AddressR1C1
Returns the range reference in the language of the macro using R1C1-style reference. Read-only String.
Declaration
public string AddressR1C1 { get; }
Property Value
Type |
---|
System.String |
AddressR1C1Local
Returns the range reference for the specified range in the language of the user using R1C1 style reference . Read-only String.
Declaration
public string AddressR1C1Local { get; }
Property Value
Type |
---|
System.String |
Boolean
Gets / sets boolean value that is contained by this range.
Declaration
public bool Boolean { get; set; }
Property Value
Type |
---|
System.Boolean |
Borders
Returns a Borders collection that represents the borders of a style or a range of cells (including a range defined as part of a conditional format).
Declaration
public IBorders Borders { get; }
Property Value
Type |
---|
IBorders |
BuiltInStyle
Gets/sets built in style.
Declaration
public Nullable<BuiltInStyles> BuiltInStyle { get; set; }
Property Value
Type |
---|
System.Nullable<BuiltInStyles> |
CalculatedValue
Returns the calculated value of a formula using the most current inputs.
Declaration
public string CalculatedValue { get; }
Property Value
Type |
---|
System.String |
Cells
Returns a Range object that represents the cells in the specified range. For big number of ranges can be very slow operation. Read-only.
Declaration
public IRange[] Cells { get; }
Property Value
Type |
---|
IRange[] |
CellsCount
Number of cells in the range. Read-only.
Declaration
public int CellsCount { get; }
Property Value
Type |
---|
System.Int32 |
CellStyle
Returns a Style object that represents the style of the specified range. Read/write IStyle.
Declaration
public IStyle CellStyle { get; set; }
Property Value
Type |
---|
IStyle |
CellStyleName
Returns name of the Style object that represents the style of the specified range. Read/write String.
Declaration
public string CellStyleName { get; set; }
Property Value
Type |
---|
System.String |
Column
Returns the number of the first column in the first area in the specified range. Read-only.
Declaration
public int Column { get; }
Property Value
Type |
---|
System.Int32 |
ColumnGroupLevel
Column group level. Read-only. -1 - Not all columns in the range have same group level. 0 - No grouping, 1 - 7 - Group level.
Declaration
public int ColumnGroupLevel { get; }
Property Value
Type |
---|
System.Int32 |
Columns
For a Range object, returns an array of Range objects that represent the columns in the specified range.
Declaration
public IRange[] Columns { get; }
Property Value
Type |
---|
IRange[] |
ColumnWidth
Returns or sets the width of all columns in the specified range. Read/write Double.
Declaration
public double ColumnWidth { get; set; }
Property Value
Type |
---|
System.Double |
Comment
Comment assigned to the range. Read-only.
Declaration
public ICommentShape Comment { get; }
Property Value
Type |
---|
ICommentShape |
ConditionalFormats
Collection of conditional formats.
Declaration
public IConditionalFormats ConditionalFormats { get; }
Property Value
Type |
---|
IConditionalFormats |
DataValidation
Data validation for the range.
Declaration
public IDataValidation DataValidation { get; }
Property Value
Type |
---|
IDataValidation |
DateTime
Gets / sets DateTime contained by this cell. Read-write DateTime.
Declaration
public DateTime DateTime { get; set; }
Property Value
Type |
---|
System.DateTime |
DisplayText
Returns cell value after number format application. Read-only.
Declaration
public string DisplayText { get; }
Property Value
Type |
---|
System.String |
End
Returns a Range object that represents the cell at the end of the region that contains the source range.
Declaration
public IRange End { get; }
Property Value
Type |
---|
IRange |
EntireColumn
Returns a Range object that represents the entire column (or columns) that contains the specified range. Read-only.
Declaration
public IRange EntireColumn { get; }
Property Value
Type |
---|
IRange |
EntireRow
Returns a Range object that represents the entire row (or rows) that contains the specified range. Read-only.
Declaration
public IRange EntireRow { get; }
Property Value
Type |
---|
IRange |
Error
Gets / sets error value that is contained by this range.
Declaration
public string Error { get; set; }
Property Value
Type |
---|
System.String |
Formula
Returns or sets the object's formula in A1-style notation and in the language of the macro. Read/write Variant.
Declaration
public string Formula { get; set; }
Property Value
Type |
---|
System.String |
FormulaArray
Represents array-entered formula. Visit http://www.cpearson.com/excel/array.htm for more information.
Declaration
public string FormulaArray { get; set; }
Property Value
Type |
---|
System.String |
FormulaArrayR1C1
Returns or sets the array-entered formula in R1C1-style notation and in the language of the macro. Read/write Variant.
Declaration
public string FormulaArrayR1C1 { get; set; }
Property Value
Type |
---|
System.String |
FormulaBoolValue
Returns the calculated value of the formula as a boolean.
Declaration
public bool FormulaBoolValue { get; set; }
Property Value
Type |
---|
System.Boolean |
FormulaDateTime
Get / set formula DateTime value contained by this cell. DateTime.MinValue if not all cells of the range have same DateTime value.
Declaration
public DateTime FormulaDateTime { get; set; }
Property Value
Type |
---|
System.DateTime |
FormulaErrorValue
Returns the calculated value of the formula as a string.
Declaration
public string FormulaErrorValue { get; set; }
Property Value
Type |
---|
System.String |
FormulaHidden
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.
Declaration
public bool FormulaHidden { get; set; }
Property Value
Type |
---|
System.Boolean |
FormulaNumberValue
Declaration
public double FormulaNumberValue { get; set; }
Property Value
Type |
---|
System.Double |
FormulaR1C1
Returns or sets the object's formula in R1C1-style notation and in the language of the macro. Read/write Variant.
Declaration
public string FormulaR1C1 { get; set; }
Property Value
Type |
---|
System.String |
FormulaStringValue
Declaration
public string FormulaStringValue { get; set; }
Property Value
Type |
---|
System.String |
HasBoolean
Indicates whether range contains bool value. Read-only.
Declaration
public bool HasBoolean { get; }
Property Value
Type |
---|
System.Boolean |
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.
Declaration
public bool HasDataValidation { get; }
Property Value
Type |
---|
System.Boolean |
HasDateTime
Indicates whether range contains DateTime value. Read-only.
Declaration
public bool HasDateTime { get; }
Property Value
Type |
---|
System.Boolean |
HasExternalFormula
Indicates is current range has external formula. Read-only.
Declaration
public bool HasExternalFormula { get; }
Property Value
Type |
---|
System.Boolean |
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.
Declaration
public bool HasFormula { get; }
Property Value
Type |
---|
System.Boolean |
HasFormulaArray
Indicates whether range contains array-entered formula. Read-only.
Declaration
public bool HasFormulaArray { get; }
Property Value
Type |
---|
System.Boolean |
HasFormulaBoolValue
Indicates if current range has formula bool value. Read-only.
Declaration
public bool HasFormulaBoolValue { get; }
Property Value
Type |
---|
System.Boolean |
HasFormulaDateTime
Indicates if current range has formula value formatted as DateTime. Read-only.
Declaration
public bool HasFormulaDateTime { get; }
Property Value
Type |
---|
System.Boolean |
HasFormulaErrorValue
Indicates if current range has formula error value. Read-only.
Declaration
public bool HasFormulaErrorValue { get; }
Property Value
Type |
---|
System.Boolean |
HasFormulaNumberValue
Gets whether the range has formula number value
Declaration
public bool HasFormulaNumberValue { get; }
Property Value
Type |
---|
System.Boolean |
HasFormulaStringValue
Gets whether the range has formula string value
Declaration
public bool HasFormulaStringValue { get; }
Property Value
Type |
---|
System.Boolean |
HasNumber
Indicates whether the range contains number. Read-only.
Declaration
public bool HasNumber { get; }
Property Value
Type |
---|
System.Boolean |
HasRichText
Indicates whether cell contains formatted rich text string.
Declaration
public bool HasRichText { get; }
Property Value
Type |
---|
System.Boolean |
HasString
Indicates whether the range contains String. Read-only.
Declaration
public bool HasString { get; }
Property Value
Type |
---|
System.Boolean |
HasStyle
Indicates whether range has default style. False means default style. Read-only.
Declaration
public bool HasStyle { get; }
Property Value
Type |
---|
System.Boolean |
HorizontalAlignment
Returns or sets the horizontal alignment for the specified object. Read/write ExcelHAlign.
Declaration
public ExcelHAlign HorizontalAlignment { get; set; }
Property Value
Type |
---|
ExcelHAlign |
HtmlString
Gets or sets HTML string.
Declaration
public string HtmlString { get; set; }
Property Value
Type |
---|
System.String |
Hyperlinks
Returns hyperlinks for this ranges collection.
Declaration
public IHyperLinks Hyperlinks { get; }
Property Value
Type |
---|
IHyperLinks |
IgnoreErrorOptions
Represents ignore error options. If not single cell returs concatenateed flags.
Declaration
public ExcelIgnoreError IgnoreErrorOptions { get; set; }
Property Value
Type |
---|
ExcelIgnoreError |
IndentLevel
Returns or sets the indent level for the cell or range. Can be an integer from 0 to 15 for Excel 97-2003 and 250 for Excel 2007. Read/write Integer.
Declaration
public int IndentLevel { get; set; }
Property Value
Type |
---|
System.Int32 |
IsBlank
Indicates whether the range is blank. Read-only.
Declaration
public bool IsBlank { get; }
Property Value
Type |
---|
System.Boolean |
IsBoolean
Indicates whether range contains boolean value. Read-only.
Declaration
public bool IsBoolean { get; }
Property Value
Type |
---|
System.Boolean |
IsError
Indicates whether range contains error value.
Declaration
public bool IsError { get; }
Property Value
Type |
---|
System.Boolean |
IsGroupedByColumn
Indicates whether this range is grouped by column. Read-only.
Declaration
public bool IsGroupedByColumn { get; }
Property Value
Type |
---|
System.Boolean |
IsGroupedByRow
Indicates whether this range is grouped by row. Read-only.
Declaration
public bool IsGroupedByRow { get; }
Property Value
Type |
---|
System.Boolean |
IsInitialized
Indicates whether cell is initialized. Read-only.
Declaration
public bool IsInitialized { get; }
Property Value
Type |
---|
System.Boolean |
IsMerged
Indicates whether this range is part of merged range. Read-only.
Declaration
public bool IsMerged { get; }
Property Value
Type |
---|
System.Boolean |
IsStringsPreserved
Indicates whether all values in the range are preserved as strings.
Declaration
public Nullable<bool> IsStringsPreserved { get; set; }
Property Value
Type |
---|
System.Nullable<System.Boolean> |
Item[Int32]
Returns item by index from the collection.
Declaration
public IRange this[int index] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index |
Property Value
Type |
---|
IRange |
Item[Int32, Int32]
Gets / sets cell by row and index.
Declaration
public IRange this[int row, int column] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | row | |
System.Int32 | column |
Property Value
Type |
---|
IRange |
Item[Int32, Int32, Int32, Int32]
Get cell range.
Declaration
public IRange this[int row, int column, int lastRow, int lastColumn] { get; }
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | row | |
System.Int32 | column | |
System.Int32 | lastRow | |
System.Int32 | lastColumn |
Property Value
Type |
---|
IRange |
Item[String]
Get cell range.
Declaration
public IRange this[string name] { get; }
Parameters
Type | Name | Description |
---|---|---|
System.String | name |
Property Value
Type |
---|
IRange |
Item[String, Boolean]
Gets cell range. Read-only.
Declaration
public IRange this[string name, bool IsR1C1Notation] { get; }
Parameters
Type | Name | Description |
---|---|---|
System.String | name | |
System.Boolean | IsR1C1Notation |
Property Value
Type |
---|
IRange |
LastColumn
Returns last column of the range. Read-only.
Declaration
public int LastColumn { get; }
Property Value
Type |
---|
System.Int32 |
LastRow
Returns last row of the range. Read-only.
Declaration
public int LastRow { get; }
Property Value
Type |
---|
System.Int32 |
MergeArea
Returns a Range object that represents the merged range containing the specified cell. If the specified cell isn�t in a merged range, this property returns NULL. Read-only.
Declaration
public IRange MergeArea { get; }
Property Value
Type |
---|
IRange |
Number
Gets / sets double value of the range.
Declaration
public double Number { get; set; }
Property Value
Type |
---|
System.Double |
NumberFormat
Format of current cell. Analog of Style.NumberFormat property.
Declaration
public string NumberFormat { get; set; }
Property Value
Type |
---|
System.String |
RichText
String with rich text formatting. Read-only.
Declaration
public IRichTextString RichText { get; }
Property Value
Type |
---|
IRichTextString |
Row
Returns the number of the first row of the first area in the range. Read-only Long.
Declaration
public int Row { get; }
Property Value
Type |
---|
System.Int32 |
RowGroupLevel
Row group level. Read-only. -1 - Not all rows in the range have same group level. 0 - No grouping, 1 - 7 - Group level.
Declaration
public int RowGroupLevel { get; }
Property Value
Type |
---|
System.Int32 |
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.
Declaration
public double RowHeight { get; set; }
Property Value
Type |
---|
System.Double |
Rows
For a Range object, returns an array of Range objects that represent the rows in the specified range.
Declaration
public IRange[] Rows { get; }
Property Value
Type |
---|
IRange[] |
Text
Gets / sets string value of the range.
Declaration
public string Text { get; set; }
Property Value
Type |
---|
System.String |
ThreadedComment
Get the threaded comment.
Declaration
public IThreadedComment ThreadedComment { get; }
Property Value
Type |
---|
IThreadedComment |
TimeSpan
Gets / sets time value of the range.
Declaration
public TimeSpan TimeSpan { get; set; }
Property Value
Type |
---|
System.TimeSpan |
Value
Returns or sets the value of the specified range. Read/write Variant.
Declaration
public string Value { get; set; }
Property Value
Type |
---|
System.String |
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.
Declaration
public object Value2 { get; set; }
Property Value
Type |
---|
System.Object |
VerticalAlignment
Returns or sets the vertical alignment of the specified object. Read/write ExcelVAlign.
Declaration
public ExcelVAlign VerticalAlignment { get; set; }
Property Value
Type |
---|
ExcelVAlign |
Worksheet
Returns a Worksheet object that represents the worksheet containing the specified range. Read-only.
Declaration
public IWorksheet Worksheet { get; }
Property Value
Type |
---|
IWorksheet |
WorksheetName
Gets name of the parent worksheet.
Declaration
public string WorksheetName { get; }
Property Value
Type |
---|
System.String |
WrapText
True if Microsoft Excel wraps the text in the object. Read/write Boolean.
Declaration
public bool WrapText { get; set; }
Property Value
Type |
---|
System.Boolean |
Methods
Activate()
Activates a single cell, which must be inside the current selection. To select a range of cells, use the Select method.
Declaration
public IRange Activate()
Returns
Type |
---|
IRange |
Activate(Boolean)
Activages a single cell, scroll to it and activates the respective sheet To select a range of cells, use the Select method.
Declaration
public IRange Activate(bool scroll)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | scroll | True to scroll to the cell |
Returns
Type |
---|
IRange |
Add(IRange)
Adds new range to the collection.
Declaration
public void Add(IRange range)
Parameters
Type | Name | Description |
---|---|---|
IRange | range | Range to add. |
AddComment()
Adds comment to the range.
Declaration
public ICommentShape AddComment()
Returns
Type | Description |
---|---|
ICommentShape | Range's comment. |
AddRange(IRange)
Adds range to the collection.
Declaration
public void AddRange(IRange range)
Parameters
Type | Name | Description |
---|---|---|
IRange | range | Range to add. |
AddThreadedComment(String, DateTime)
Creates a threaded comment for the current cell with the specified text.
Declaration
public IThreadedComment AddThreadedComment(string text, DateTime creationTime)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | Threaded comment text |
System.DateTime | creationTime | Optional.The creation time of the threaded comment |
Returns
Type | Description |
---|---|
IThreadedComment | Returns the created instance of IThreadedComment. |
AddThreadedComment(String, String, DateTime)
Creates a threaded comment for the current cell with the specified text and author.
Declaration
public IThreadedComment AddThreadedComment(string text, string author, DateTime creationTime)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | Threaded comment text |
System.String | author | The author of the threaded comment text |
System.DateTime | creationTime | Optional.The creation time of the threaded comment |
Returns
Type | Description |
---|---|
IThreadedComment | Returns the created instance of IThreadedComment. |
AutofitColumns()
Autofits all columns in the range.
Declaration
public void AutofitColumns()
AutofitRows()
Autofits all rows in the range.
Declaration
public void AutofitRows()
Average()
Returns average of numeric cells in the range.
Declaration
public double Average()
Returns
Type |
---|
System.Double |
Average(Boolean)
Returns average of numeric cells in the range.
Declaration
public double Average(bool considerDateAsNumber)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | considerDateAsNumber | Considers numeric value of date formatted cells for calculation. |
Returns
Type |
---|
System.Double |
BorderAround()
Sets around border for current range.
Declaration
public void BorderAround()
BorderAround(ExcelLineStyle)
Sets around border for current range.
Declaration
public void BorderAround(ExcelLineStyle borderLine)
Parameters
Type | Name | Description |
---|---|---|
ExcelLineStyle | borderLine | Represents border line. |
BorderAround(ExcelLineStyle, Color)
Sets around border for current range.
Declaration
public void BorderAround(ExcelLineStyle borderLine, Color borderColor)
Parameters
Type | Name | Description |
---|---|---|
ExcelLineStyle | borderLine | Represents border line. |
Color | borderColor | Represents border color. |
BorderAround(ExcelLineStyle, ExcelKnownColors)
Sets around border for current range.
Declaration
public void BorderAround(ExcelLineStyle borderLine, ExcelKnownColors borderColor)
Parameters
Type | Name | Description |
---|---|---|
ExcelLineStyle | borderLine | Represents border line. |
ExcelKnownColors | borderColor | Represents border color as ExcelKnownColors. |
BorderInside()
Sets inside border for current range.
Declaration
public void BorderInside()
BorderInside(ExcelLineStyle)
Sets inside border for current range.
Declaration
public void BorderInside(ExcelLineStyle borderLine)
Parameters
Type | Name | Description |
---|---|---|
ExcelLineStyle | borderLine | Represents border line. |
BorderInside(ExcelLineStyle, Color)
Sets inside border for current range.
Declaration
public void BorderInside(ExcelLineStyle borderLine, Color borderColor)
Parameters
Type | Name | Description |
---|---|---|
ExcelLineStyle | borderLine | Represents border line. |
Color | borderColor | Represents border color. |
BorderInside(ExcelLineStyle, ExcelKnownColors)
Sets inside border for current range.
Declaration
public void BorderInside(ExcelLineStyle borderLine, ExcelKnownColors borderColor)
Parameters
Type | Name | Description |
---|---|---|
ExcelLineStyle | borderLine | Represents border line. |
ExcelKnownColors | borderColor | Represents border color as ExcelKnownColors. |
BorderNone()
Sets none border for current range.
Declaration
public void BorderNone()
ClearConditionalFormats()
Clears conditional formats.
Declaration
public void ClearConditionalFormats()
Clone(Object, Dictionary<String, String>, WorkbookImpl)
Clones current IRange.
Declaration
public IRange Clone(object parent, Dictionary<string, string> hashNewNames, WorkbookImpl book)
Parameters
Type | Name | Description |
---|---|---|
System.Object | parent | Parent object. |
System.Collections.Generic.Dictionary<System.String, System.String> | hashNewNames | Dictionary with new names. |
WorkbookImpl | book | Parent workbook. |
Returns
Type | Description |
---|---|
IRange | Returns clone of current instance. |
CollapseGroup(ExcelGroupBy)
Collapses current group.
Declaration
public void CollapseGroup(ExcelGroupBy groupBy)
Parameters
Type | Name | Description |
---|---|---|
ExcelGroupBy | groupBy | This parameter specifies whether the grouping should be performed by rows or by columns. |
CopyTo(IRange)
Copies the range to the specified destination Range (without updating formulas).
Declaration
public IRange CopyTo(IRange destination)
Parameters
Type | Name | Description |
---|---|---|
IRange | destination | Destination range. |
Returns
Type | Description |
---|---|
IRange | Range were this range was copied. |
CopyTo(IRange, ExcelCopyRangeOptions)
Copies this range into another location.
Declaration
public IRange CopyTo(IRange destination, ExcelCopyRangeOptions options)
Parameters
Type | Name | Description |
---|---|---|
IRange | destination | Destination range. |
ExcelCopyRangeOptions | options | Copy range options. |
Returns
Type | Description |
---|---|
IRange | Destination range. |
CopyTo(IRange, ExcelCopyRangeOptions, Boolean)
Copies the Range to the specified destination Range with copy options and skip blank option.
Declaration
public IRange CopyTo(IRange destination, ExcelCopyRangeOptions options, bool skipBlank)
Parameters
Type | Name | Description |
---|---|---|
IRange | destination | Represents the destination Range to copy. |
ExcelCopyRangeOptions | options | Represents the copy Range options. |
System.Boolean | skipBlank | Represents the skip blank cells in the source. |
Returns
Type | Description |
---|---|
IRange | Returns the copied Range. |
CopyTo(IRange, Boolean)
Copies the Range to the specified destination Range with copy options.
Declaration
public IRange CopyTo(IRange destination, bool pasteLink)
Parameters
Type | Name | Description |
---|---|---|
IRange | destination | Represents the destination Range to copy. |
System.Boolean | pasteLink | Represents if the pasteLinkOptions implement or not . |
Returns
Type | Description |
---|---|
IRange | Returns the copied Range. |
Examples
The following code illustrates how to copy the Range with pasteLink options.
ExcelEngine engine = new ExcelEngine();
IApplication application = engine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
IWorksheet sheet = workbook.Worksheets[0];
IRange sourceRange1 = sheet.Range["A1:A3"];
IRange sourceRange2 = sheet.Range["A5"];
IRange sourceRange3 = sheet.Range["A8:A10"];
IRange sourceRange4 = sheet.Range["A12:A16"];
IRange sourceRange5 = sheet.Range["A22:A30"];
IRange sourceRange6 = sheet.Range["A35:A37"];
IRange sourceRange7 = sheet.Range["A38"];
IRanges sourceRanges = sheet.CreateRangesCollection();
sourceRanges.Add(sourceRange1);
sourceRanges.Add(sourceRange2);
sourceRanges.Add(sourceRange3);
sourceRanges.Add(sourceRange4);
sourceRanges.Add(sourceRange5);
sourceRanges.Add(sourceRange6);
sourceRanges.Add(sourceRange7);
IRange destination = sheet.Range["C1"];
// Copy range as link from source to destination
sourceRanges.CopyTo(destination, true);
workbook.Version = ExcelVersion.Excel2013;
workbook.SaveAs("CopyRange.xlsx");
workbook.Close();
engine.Dispose();
CopyToClipboard()
Copies range to the clipboard.
Declaration
public void CopyToClipboard()
ExpandGroup(ExcelGroupBy)
Expands current group.
Declaration
public void ExpandGroup(ExcelGroupBy groupBy)
Parameters
Type | Name | Description |
---|---|---|
ExcelGroupBy | groupBy | This parameter specifies whether the grouping should be performed by rows or by columns. |
ExpandGroup(ExcelGroupBy, ExpandCollapseFlags)
Expands current group.
Declaration
public void ExpandGroup(ExcelGroupBy groupBy, ExpandCollapseFlags flags)
Parameters
Type | Name | Description |
---|---|---|
ExcelGroupBy | groupBy | This parameter specifies whether the grouping should be performed by rows or by columns. |
ExpandCollapseFlags | flags | Additional option flags. |
FindAll(Boolean)
This method searches for the all cells with specified bool value.
Declaration
public IRange[] FindAll(bool findValue)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | findValue | Value to search. |
Returns
Type | Description |
---|---|
IRange[] | All found cells, or Null if value was not found |
FindAll(DateTime)
This method searches for the all cells with specified DateTime value.
Declaration
public IRange[] FindAll(DateTime findValue)
Parameters
Type | Name | Description |
---|---|---|
System.DateTime | findValue | Value to search. |
Returns
Type | Description |
---|---|
IRange[] | All found cells, or Null if value was not found. |
FindAll(Double, ExcelFindType)
This method searches for the all cells with specified double value.
Declaration
public IRange[] FindAll(double findValue, ExcelFindType flags)
Parameters
Type | Name | Description |
---|---|---|
System.Double | findValue | Value to search. |
ExcelFindType | flags | Type of value to search. |
Returns
Type | Description |
---|---|
IRange[] | All found cells, or Null if value was not found. |
FindAll(String, ExcelFindType)
This method searches for the all cells with specified string value.
Declaration
public IRange[] FindAll(string findValue, ExcelFindType flags)
Parameters
Type | Name | Description |
---|---|---|
System.String | findValue | Value to search. |
ExcelFindType | flags | Type of value to search. |
Returns
Type | Description |
---|---|
IRange[] | All found cells, or Null if value was not found. |
FindAll(TimeSpan)
This method searches for the all cells with specified TimeSpan value.
Declaration
public IRange[] FindAll(TimeSpan findValue)
Parameters
Type | Name | Description |
---|---|---|
System.TimeSpan | findValue | Value to search. |
Returns
Type | Description |
---|---|
IRange[] | All found cells, or Null if value was not found. |
FindFirst(Boolean)
This method searches for the first cell with specified bool value.
Declaration
public IRange FindFirst(bool findValue)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | findValue | Value to search. |
Returns
Type | Description |
---|---|
IRange | First found cell, or Null if value was not found. |
FindFirst(DateTime)
This method searches for the first cell with specified DateTime value.
Declaration
public IRange FindFirst(DateTime findValue)
Parameters
Type | Name | Description |
---|---|---|
System.DateTime | findValue | Value to search. |
Returns
Type | Description |
---|---|
IRange | First found cell, or Null if value was not found. |
FindFirst(Double, ExcelFindType)
This method searches for the first cell with specified double value.
Declaration
public IRange FindFirst(double findValue, ExcelFindType flags)
Parameters
Type | Name | Description |
---|---|---|
System.Double | findValue | Value to search. |
ExcelFindType | flags | Type of value to search. |
Returns
Type | Description |
---|---|
IRange | First found cell, or Null if value was not found. |
FindFirst(String, ExcelFindType)
This method searches for the first cell with specified string value.
Declaration
public IRange FindFirst(string findValue, ExcelFindType flags)
Parameters
Type | Name | Description |
---|---|---|
System.String | findValue | Value to search. |
ExcelFindType | flags | Type of value to search. |
Returns
Type | Description |
---|---|
IRange | First found cell, or Null if value was not found. |
FindFirst(TimeSpan)
This method searches for the first cell with specified TimeSpan value.
Declaration
public IRange FindFirst(TimeSpan findValue)
Parameters
Type | Name | Description |
---|---|---|
System.TimeSpan | findValue | Value to search. |
Returns
Type | Description |
---|---|
IRange | First found cell, or Null if value was not found. |
FreezePanes()
Freezes pane at the current range.
Declaration
public void FreezePanes()
GetDependents()
Gets the dependent cells which refer to other cells.
Declaration
public IRange[] GetDependents()
Returns
Type | Description |
---|---|
IRange[] | Returns the dependent cells or null if value was not found. |
Examples
The following code illustrates how to get the dependent cells from the worksheet.
ExcelEngine excelEngine = new ExcelEngine();
IApplication application = excelEngine.Excel;
IWorkbook workbook = application.Workbooks.Open("FormulaExcel.xlsx");
IWorksheet sheet = workbook.Worksheets[0];
IRange[] results = sheet["A1"].GetDependents();
string fileName = "Dependents.xlsx";
workbook.SaveAs(fileName);
workbook.Close();
excelEngine.Dispose();
GetDependents(Boolean)
Gets the dependent cells which refer to other cells.
Declaration
public IRange[] GetDependents(bool isEntireWorkbook)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | isEntireWorkbook | Indicates whether to check from other worksheets. |
Returns
Type | Description |
---|---|
IRange[] | Returns the dependent cells with a specified bool value or null if value was not found. |
Examples
The following code illustrates how to get the dependents cells from all the worksheets.
ExcelEngine excelEngine = new ExcelEngine();
IApplication application = excelEngine.Excel;
IWorkbook workbook = application.Workbooks.Open("FormulaExcel.xlsx");
IWorksheet sheet = workbook.Worksheets[0];
IRange[] results = sheet["A1"].GetDependents(true);
string fileName = "Dependents.xlsx";
workbook.SaveAs(fileName);
workbook.Close();
excelEngine.Dispose();
GetDirectDependents()
Gets the direct dependent cells which refer to other cells.
Declaration
public IRange[] GetDirectDependents()
Returns
Type | Description |
---|---|
IRange[] | Returns the direct dependent cells or null if value was not found. |
Examples
The following code illustrates how to get the direct dependent cells from the worksheet.
ExcelEngine excelEngine = new ExcelEngine();
IApplication application = excelEngine.Excel;
IWorkbook workbook = application.Workbooks.Open("FormulaExcel.xlsx");
IWorksheet sheet = workbook.Worksheets[0];
IRange[] results = sheet["A1"].GetDirectDependents();
string fileName = "Dependents.xlsx";
workbook.SaveAs(fileName);
workbook.Close();
excelEngine.Dispose();
GetDirectDependents(Boolean)
Gets the direct dependent cells which refer to other cells.
Declaration
public IRange[] GetDirectDependents(bool isEntireWorkbook)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | isEntireWorkbook | Indicates whether to check from other worksheets. |
Returns
Type | Description |
---|---|
IRange[] | Returns the direct dependent cells with a specified bool value or null if value was not found. |
Examples
The following code illustrates how to get the direct dependents cells from all the worksheets.
ExcelEngine excelEngine = new ExcelEngine();
IApplication application = excelEngine.Excel;
IWorkbook workbook = application.Workbooks.Open("FormulaExcel.xlsx");
IWorksheet sheet = workbook.Worksheets[0];
IRange[] results = sheet["A1"].GetDirectDependents(true);
string fileName = "Dependents.xlsx";
workbook.SaveAs(fileName);
workbook.Close();
excelEngine.Dispose();
GetDirectPrecedents()
Gets the direct precedent cells which are referred by a formula in another cell.
Declaration
public IRange[] GetDirectPrecedents()
Returns
Type | Description |
---|---|
IRange[] | Returns the direct precedent cells or null if value was not found. |
Examples
The following code illustrates how to get the direct precedent cells from the worksheet.
ExcelEngine excelEngine = new ExcelEngine();
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Open("FormulaExcel.xlsx");
IWorksheet sheet = workbook.Worksheets[0];
IRange[] results = sheet["A1"].GetDirectPrecedents();
string fileName = "Precedents.xlsx";
workbook.SaveAs(fileName);
workbook.Close();
excelEngine.Dispose();
GetDirectPrecedents(Boolean)
Gets the direct precedent cells which are referred by a formula in another cell.
Declaration
public IRange[] GetDirectPrecedents(bool isEntireWorkbook)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | isEntireWorkbook | Indicates whether to check from other worksheets. |
Returns
Type | Description |
---|---|
IRange[] | Returns the direct precedent cells with a specified bool value or null if value was not found. |
Examples
The following code illustrates how to get the direct precedent cells from all the worksheets.
ExcelEngine excelEngine = new ExcelEngine();
IApplication application = excelEngine.Excel;
IWorkbook workbook = application.Workbooks.Open("FormulaExcel.xlsx");
IWorksheet sheet = workbook.Worksheets[0];
IRange[] results = sheet["A1"].GetDirectPrecedents(true);
string fileName = "Precedents.xlsx";
workbook.SaveAs(fileName);
workbook.Close();
excelEngine.Dispose();
GetEnumerator()
Returns an IEnumerator
Declaration
public IEnumerator GetEnumerator()
Returns
Type |
---|
System.Collections.IEnumerator |
GetNativePtg()
Gets ptg of current range.
Declaration
public Ptg[] GetNativePtg()
Returns
Type | Description |
---|---|
Ptg[] | Returns native ptg. |
GetNewAddress(Dictionary<String, String>, out String)
Gets new address of range.
Declaration
public string GetNewAddress(Dictionary<string, string> names, out string strSheetName)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.Dictionary<System.String, System.String> | names | Dictionary with Worksheet names. |
System.String | strSheetName | String that sets as a worksheet name. |
Returns
Type | Description |
---|---|
System.String | Returns string with new name. |
GetPrecedents()
Gets the precedent cells which are referred by a formula in another cell.
Declaration
public IRange[] GetPrecedents()
Returns
Type | Description |
---|---|
IRange[] | Returns the precedent cells or null if value was not found. |
Examples
The following code illustrates how to get the precedent cells from the worksheet.
ExcelEngine excelEngine = new ExcelEngine();
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Open("FormulaExcel.xlsx");
IWorksheet sheet = workbook.Worksheets[0];
IRange[] results = sheet["A1"].GetPrecedents();
string fileName = "Precedents.xlsx";
workbook.SaveAs(fileName);
workbook.Close();
excelEngine.Dispose();
GetPrecedents(Boolean)
Gets the precedent cells which are referred by a formula in another cell.
Declaration
public IRange[] GetPrecedents(bool isEntireWorkbook)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | isEntireWorkbook | Indicates whether to check from other worksheets. |
Returns
Type | Description |
---|---|
IRange[] | Returns the precedent cells with a specified bool value or null if value was not found. |
Examples
The following code illustrates how to get the precedent cells from all the worksheets.
ExcelEngine excelEngine = new ExcelEngine();
IApplication application = excelEngine.Excel;
IWorkbook workbook = application.Workbooks.Open("FormulaExcel.xlsx");
IWorksheet sheet = workbook.Worksheets[0];
IRange[] results = sheet["A1"].GetPrecedents(true);
string fileName = "Precedents.xlsx";
workbook.SaveAs(fileName);
workbook.Close();
excelEngine.Dispose();
GetRectangles()
Returns array that contains information about range.
Declaration
public Rectangle[] GetRectangles()
Returns
Type | Description |
---|---|
Rectangle[] | Rectangles that describes range |
GetRectanglesCount()
Returns number of rectangles returned by GetRectangles method.
Declaration
public int GetRectanglesCount()
Returns
Type | Description |
---|---|
System.Int32 | Number of rectangles returned by GetRectangles method. |
Group(ExcelGroupBy)
This method groups current range.
Declaration
public IRange Group(ExcelGroupBy groupBy)
Parameters
Type | Name | Description |
---|---|---|
ExcelGroupBy | groupBy | This parameter specifies whether the grouping should be performed by rows or by columns. |
Returns
Type | Description |
---|---|
IRange | Current range after grouping. |
Group(ExcelGroupBy, Boolean)
This method groups current range.
Declaration
public IRange Group(ExcelGroupBy groupBy, bool bCollapsed)
Parameters
Type | Name | Description |
---|---|---|
ExcelGroupBy | groupBy | This parameter specifies whether grouping should be performed by rows or by columns. |
System.Boolean | bCollapsed | Indicates whether group should be collapsed. |
Returns
Type | Description |
---|---|
IRange | Current range after grouping. |
IntersectWith(IRange)
Returns intersection of this range with the specified one.
Declaration
public IRange IntersectWith(IRange range)
Parameters
Type | Name | Description |
---|---|---|
IRange | range | The Range with which to intersect. |
Returns
Type | Description |
---|---|
IRange | Range intersection; if there is no intersection, NULL is returned. |
Max()
Returns maximum value from numeric cells in the range.
Declaration
public double Max()
Returns
Type |
---|
System.Double |
Max(Boolean)
Returns maximum value from numeric cells in the range.
Declaration
public double Max(bool considerDateAsNumber)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | considerDateAsNumber | Considers numeric value of date formatted cells for calculation. |
Returns
Type |
---|
System.Double |
Merge()
Creates a merged cell from the specified Range object.
Declaration
public void Merge()
Merge(Boolean)
Creates a merged cell from the specified Range object.
Declaration
public void Merge(bool clearCells)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | clearCells | Indicates whether to clear unnecessary cells. |
MergeWith(IRange)
Returns merge of this range with the specified one.
Declaration
public IRange MergeWith(IRange range)
Parameters
Type | Name | Description |
---|---|---|
IRange | range | The Range to merge with. |
Returns
Type | Description |
---|---|
IRange | Merged ranges or NULL if wasn't able to merge ranges. |
Min()
Returns minumum value from numeric cells in the range.
Declaration
public double Min()
Returns
Type |
---|
System.Double |
Min(Boolean)
Returns minumum value from numeric cells in the range.
Declaration
public double Min(bool considerDateAsNumber)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | considerDateAsNumber | Considers numeric value of date formatted cells for calculation. |
Returns
Type |
---|
System.Double |
MoveTo(IRange)
Moves the cells to the specified Range (without updating formulas).
Declaration
public void MoveTo(IRange destination)
Parameters
Type | Name | Description |
---|---|---|
IRange | destination | Destination Range. |
Offset(Int32, Int32)
Returns a Range object that represents a range thats offset from the specified range.
Declaration
public IRange Offset(int row, int column)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | row | The number of rows (positive, negative, or 0 (zero)) by which the range is to be offset |
System.Int32 | column | The number of columns (positive, negative, or 0 (zero)) by which the range is to be offset |
Returns
Type |
---|
IRange |
Remove(IRange)
Removes range from the collection.
Declaration
public void Remove(IRange range)
Parameters
Type | Name | Description |
---|---|---|
IRange | range | Range to remove. |
Replace(String, DataColumn, Boolean)
Replaces the string with the specified datacolumn.
Declaration
public void Replace(string oldValue, DataColumn newValues, bool isFieldNamesShown)
Parameters
Type | Name | Description |
---|---|---|
System.String | oldValue | The string to be replaced. |
System.Data.DataColumn | newValues | DataColumn with new data. |
System.Boolean | isFieldNamesShown | Indicates whether field name must be shown. |
Replace(String, DataTable, Boolean)
Replaces the string with the specified datatable.
Declaration
public void Replace(string oldValue, DataTable newValues, bool isFieldNamesShown)
Parameters
Type | Name | Description |
---|---|---|
System.String | oldValue | The string to be replaced. |
System.Data.DataTable | newValues | Data table with new data. |
System.Boolean | isFieldNamesShown | Indicates whether field name must be shown. |
Replace(String, DateTime)
Replaces the string with the specified DateTime value.
Declaration
public void Replace(string oldValue, DateTime newValue)
Parameters
Type | Name | Description |
---|---|---|
System.String | oldValue | The string to be replaced. |
System.DateTime | newValue | The datetime value to replace all occurrences of oldValue. |
Replace(String, Double)
Replaces the string with the specified double value.
Declaration
public void Replace(string oldValue, double newValue)
Parameters
Type | Name | Description |
---|---|---|
System.String | oldValue | The string to be replaced. |
System.Double | newValue | The double value to replace all occurrences of oldValue. |
Replace(String, Double[], Boolean)
Replaces the string with the specified array of double values.
Declaration
public void Replace(string oldValue, double[] newValues, bool isVertical)
Parameters
Type | Name | Description |
---|---|---|
System.String | oldValue | The string to be replaced. |
System.Double[] | newValues | Array of new values. |
System.Boolean | isVertical | Indicates whether array should be inserted vertically. |
Replace(String, Int32[], Boolean)
Replaces the string with the specified array of int values.
Declaration
public void Replace(string oldValue, int[] newValues, bool isVertical)
Parameters
Type | Name | Description |
---|---|---|
System.String | oldValue | The string to be replaced. |
System.Int32[] | newValues | Array of new values. |
System.Boolean | isVertical | Indicates whether array should be inserted vertically. |
Replace(String, String)
Replaces the string with the specified string value.
Declaration
public void Replace(string oldValue, string newValue)
Parameters
Type | Name | Description |
---|---|---|
System.String | oldValue | The string to be replaced. |
System.String | newValue | The string to replace all occurrences of oldValue. |
Replace(String, String, ExcelFindOptions)
Replaces the string with the specified string value based on the given ExcelFindOptions.
Declaration
public void Replace(string oldValue, string newValue, ExcelFindOptions findOptions)
Parameters
Type | Name | Description |
---|---|---|
System.String | oldValue | The string to be replaced. |
System.String | newValue | The string to replace all occurrences of oldValue. |
ExcelFindOptions | findOptions | Specifies the find options for the oldValue. |
Replace(String, String[], Boolean)
Replaces the string with the specified array of string values.
Declaration
public void Replace(string oldValue, string[] newValues, bool isVertical)
Parameters
Type | Name | Description |
---|---|---|
System.String | oldValue | The string to be replaced. |
System.String[] | newValues | Array of new values. |
System.Boolean | isVertical | Indicates whether array should be inserted vertically. |
Resize(Int32, Int32)
Resizes the specified range
Declaration
public IRange Resize(int row, int column)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | row | The number of rows in new range |
System.Int32 | column | The number of columns in new range |
Returns
Type |
---|
IRange |
SubTotal(Int32, ConsolidationFunction, Int32[])
Creates Subtotal for the corresponding ranges
Declaration
public void SubTotal(int groupBy, ConsolidationFunction function, int[] totalList)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | groupBy | GroupBy |
ConsolidationFunction | function | ConsolidationFunction |
System.Int32[] | totalList | TotalList |
SubTotal(Int32, ConsolidationFunction, Int32[], Boolean, Boolean, Boolean)
Creates SubTotal for the corresponding Ranges
Declaration
public void SubTotal(int groupBy, ConsolidationFunction function, int[] totalList, bool replace, bool pageBreaks, bool summaryBelowData)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | groupBy | GroupByGroupBy |
ConsolidationFunction | function | ConsolidationFunction |
System.Int32[] | totalList | TotalList |
System.Boolean | replace | Replace exisiting SubTotal |
System.Boolean | pageBreaks | Insert PageBreaks |
System.Boolean | summaryBelowData | SummaryBelowData |
SubTotal(Int32[], ConsolidationFunction, Int32[], Boolean, Boolean, Boolean)
Creates SubTotal for the corresponding Ranges
Declaration
public void SubTotal(int[] groupBy, ConsolidationFunction function, int[] totalList, bool replace, bool pageBreaks, bool summaryBelowData)
Parameters
Type | Name | Description |
---|---|---|
System.Int32[] | groupBy | Columns to GroupBy |
ConsolidationFunction | function | ConsolidationFunction |
System.Int32[] | totalList | TotalList |
System.Boolean | replace | Replace exisiting SubTotal |
System.Boolean | pageBreaks | Insert PageBreaks |
System.Boolean | summaryBelowData | SummaryBelowData |
Sum()
Returns sum of numeric cells in the range.
Declaration
public double Sum()
Returns
Type |
---|
System.Double |
Sum(Boolean)
Returns sum of numeric cells in the range.
Declaration
public double Sum(bool considerDateAsNumber)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | considerDateAsNumber | Considers numeric value of date formatted cells for calculation. |
Returns
Type |
---|
System.Double |
Trim()
Trim the empty rows at top and bottom of the range, the empty columns at left and right of the range.
Declaration
public IRange Trim()
Returns
Type | Description |
---|---|
IRange | Returns the range after trim. |
Ungroup(ExcelGroupBy)
Ungroups current range.
Declaration
public IRange Ungroup(ExcelGroupBy groupBy)
Parameters
Type | Name | Description |
---|---|---|
ExcelGroupBy | groupBy | Indicates type of ungrouping. Ungroup by columns or by rows. |
Returns
Type | Description |
---|---|
IRange | Current range after ungrouping. |
UnMerge()
Separates a merged area into individual cells.
Declaration
public void UnMerge()
Explicit Interface Implementations
IRange.Clear()
Clear the contents of the Range.
Declaration
void IRange.Clear()
IRange.Clear(ExcelClearOptions)
Clears the cell based on clear options.
Declaration
void IRange.Clear(ExcelClearOptions option)
Parameters
Type | Name | Description |
---|---|---|
ExcelClearOptions | option |
IRange.Clear(ExcelMoveDirection)
Clear the contents of the Range and shifts the cells Up or Left without formula or merged ranges update.
Declaration
void IRange.Clear(ExcelMoveDirection direction)
Parameters
Type | Name | Description |
---|---|---|
ExcelMoveDirection | direction | Cells shift direction Up/Left. |
IRange.Clear(ExcelMoveDirection, ExcelCopyRangeOptions)
Clear the contents of the Range and shifts the cells Up or Left.
Declaration
void IRange.Clear(ExcelMoveDirection direction, ExcelCopyRangeOptions options)
Parameters
Type | Name | Description |
---|---|---|
ExcelMoveDirection | direction | Cells shift direction Up/Left. |
ExcelCopyRangeOptions | options | Cells shifting options. |
IRange.Clear(Boolean)
Clear the contents of the Range with formatting.
Declaration
void IRange.Clear(bool isClearFormat)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | isClearFormat | True if formatting should also be cleared. |
IRange.Count
Returns the number of objects in the collection. Read-only.
Declaration
int IRange.Count { get; }
Returns
Type |
---|
System.Int32 |