Interface IXLCell
public interface IXLCell
- Extension Methods
Properties
Active
bool Active { get; set; }
Property Value
Address
Gets this cell's address, relative to the worksheet.
IXLAddress Address { get; }
Property Value
- IXLAddress
The cell's address.
CachedValue
Get the value of a cell without evaluation of a formula. If the cell contains a formula, it returns the last calculated value or a blank value. If the cell doesn't contain a formula, it returns same value as Value. May hold invalid value when NeedsRecalculation flag is True.
XLCellValue CachedValue { get; }
Property Value
Remarks
Can be useful to decrease a number of formula evaluations.
CurrentRegion
Returns the current region. The current region is a range bounded by any combination of blank rows and blank columns
IXLRange CurrentRegion { get; }
Property Value
- IXLRange
The current region.
DataType
Gets the type of this cell's data.
XLDataType DataType { get; }
Property Value
- XLDataType
The type of the cell's data.
FormulaA1
Gets or sets the cell's formula with A1 references.
string FormulaA1 { get; set; }
Property Value
- string
The formula with A1 references.
FormulaR1C1
Gets or sets the cell's formula with R1C1 references.
string FormulaR1C1 { get; set; }
Property Value
- string
The formula with R1C1 references.
FormulaReference
An indication that value of this cell is calculated by a array formula that calculates values for cells in the referenced address. Null if not part of such formula.
IXLRangeAddress FormulaReference { get; set; }
Property Value
HasArrayFormula
bool HasArrayFormula { get; }
Property Value
HasComment
bool HasComment { get; }
Property Value
HasDataValidation
bool HasDataValidation { get; }
Property Value
HasFormula
bool HasFormula { get; }
Property Value
HasHyperlink
bool HasHyperlink { get; }
Property Value
HasRichText
bool HasRichText { get; }
Property Value
HasSparkline
bool HasSparkline { get; }
Property Value
NeedsRecalculation
Flag indicating that previously calculated cell value may be not valid anymore and has to be re-evaluated.
bool NeedsRecalculation { get; }
Property Value
ShareString
Gets or sets a value indicating whether this cell's text should be shared or not.
bool ShareString { get; set; }
Property Value
- bool
If false the cell's text will not be shared and stored as an inline value.
ShowPhonetic
Should the cell show phonetic (i.e. furigana) above the rich text of the cell?
It shows phonetic runs in the rich text, it is not autogenerated. Default
is false.
bool ShowPhonetic { get; set; }
Property Value
Sparkline
IXLSparkline Sparkline { get; }
Property Value
Style
Gets or sets the cell's style.
IXLStyle Style { get; set; }
Property Value
Value
Gets or sets the cell's value.
Getter will return value of a cell or value of formula. Getter will evaluate a formula, if the cell NeedsRecalculation, before returning up-to-date value.
Setter will clear a formula, if the cell contains a formula. If the value is a text that starts with a single quote, setter will prefix the value with a single quote through IncludeQuotePrefix in Excel too and the value of cell is set to to non-quoted text.
XLCellValue Value { get; set; }
Property Value
Worksheet
IXLWorksheet Worksheet { get; }
Property Value
Methods
AddConditionalFormat()
IXLConditionalFormat AddConditionalFormat()
Returns
AddToNamed(string)
Creates a named range out of this cell.
If the named range exists, it will add this range to that named range.
The default scope for the named range is Workbook.
IXLCell AddToNamed(string rangeName)
Parameters
rangeNamestringName of the range.
Returns
AddToNamed(string, XLScope)
Creates a named range out of this cell.
If the named range exists, it will add this range to that named range.
Name of the range. The scope for the named range.IXLCell AddToNamed(string rangeName, XLScope scope)
Parameters
Returns
AddToNamed(string, XLScope, string)
Creates a named range out of this cell.
If the named range exists, it will add this range to that named range.
Name of the range. The scope for the named range. The comments for the named range.IXLCell AddToNamed(string rangeName, XLScope scope, string comment)
Parameters
Returns
AsRange()
Returns this cell as an IXLRange.
IXLRange AsRange()
Returns
CellAbove()
IXLCell CellAbove()
Returns
CellAbove(int)
IXLCell CellAbove(int step)
Parameters
stepint
Returns
CellBelow()
IXLCell CellBelow()
Returns
CellBelow(int)
IXLCell CellBelow(int step)
Parameters
stepint
Returns
CellLeft()
IXLCell CellLeft()
Returns
CellLeft(int)
IXLCell CellLeft(int step)
Parameters
stepint
Returns
CellRight()
IXLCell CellRight()
Returns
CellRight(int)
IXLCell CellRight(int step)
Parameters
stepint
Returns
Clear(XLClearOptions)
Clears the contents of this cell.
IXLCell Clear(XLClearOptions clearOptions = XLClearOptions.All)
Parameters
clearOptionsXLClearOptionsSpecify what you want to clear.
Returns
CopyFrom(IXLCell)
IXLCell CopyFrom(IXLCell otherCell)
Parameters
otherCellIXLCell
Returns
CopyFrom(IXLRangeBase)
Copy range content to an area of same size starting at the cell. Original content of cells is overwritten.
IXLCell CopyFrom(IXLRangeBase rangeBase)
Parameters
rangeBaseIXLRangeBaseRange whose content to copy.
Returns
- IXLCell
This cell.
CopyFrom(string)
IXLCell CopyFrom(string otherCell)
Parameters
otherCellstring
Returns
CopyTo(IXLCell)
IXLCell CopyTo(IXLCell target)
Parameters
targetIXLCell
Returns
CopyTo(string)
IXLCell CopyTo(string target)
Parameters
targetstring
Returns
CreateComment()
Creates a new comment for the cell, replacing the existing one.
IXLComment CreateComment()
Returns
CreateDataValidation()
Creates a new data validation rule for the cell, replacing the existing one.
IXLDataValidation CreateDataValidation()
Returns
CreateHyperlink()
Creates a new hyperlink replacing the existing one.
XLHyperlink CreateHyperlink()
Returns
CreateRichText()
Replaces a value of the cell with a newly created rich text object.
IXLRichText CreateRichText()
Returns
Delete(XLShiftDeletedCells)
Deletes the current cell and shifts the surrounding cells according to the shiftDeleteCells parameter.
void Delete(XLShiftDeletedCells shiftDeleteCells)
Parameters
shiftDeleteCellsXLShiftDeletedCellsHow to shift the surrounding cells.
GetBoolean()
Gets the cell's value as a Boolean.
bool GetBoolean()
Returns
Remarks
Shortcut for Value.GetBoolean()
Exceptions
- InvalidCastException
If the value of the cell is not a logical.
GetComment()
Returns the comment for the cell or create a new instance if there is no comment on the cell.
IXLComment GetComment()
Returns
GetDataValidation()
Returns a data validation rule assigned to the cell, if any, or creates a new instance of data validation rule if no rule exists.
IXLDataValidation GetDataValidation()
Returns
GetDateTime()
Gets the cell's value as a DateTime.
DateTime GetDateTime()
Returns
Remarks
Shortcut for Value.GetDateTime()
Exceptions
- InvalidCastException
If the value of the cell is not a DateTime.
GetDouble()
Gets the cell's value as a Double.
double GetDouble()
Returns
Remarks
Shortcut for Value.GetNumber()
Exceptions
- InvalidCastException
If the value of the cell is not a number.
GetError()
Gets the cell's value as a XLError.
XLError GetError()
Returns
Remarks
Shortcut for Value.GetError()
Exceptions
- InvalidCastException
If the value of the cell is not an error.
GetFormattedString()
Gets the cell's value formatted depending on the cell's data type and style.
string GetFormattedString()
Returns
GetHyperlink()
Returns a hyperlink for the cell, if any, or creates a new instance is there is no hyperlink.
XLHyperlink GetHyperlink()
Returns
GetRichText()
Returns the value of the cell if it formatted as a rich text.
IXLRichText GetRichText()
Returns
GetString()
Return cell's value represented as a string. Doesn't use cell's formatting or style.
string GetString()
Returns
GetText()
Gets the cell's value as a String.
string GetText()
Returns
Remarks
Shortcut for Value.GetText(). Returned value is never null.
Exceptions
- InvalidCastException
If the value of the cell is not a text.
GetTimeSpan()
Gets the cell's value as a TimeSpan.
TimeSpan GetTimeSpan()
Returns
Remarks
Shortcut for Value.GetTimeSpan()
Exceptions
- InvalidCastException
If the value of the cell is not a TimeSpan.
GetValue<T>()
Try to get cell's value converted to the T type.
Supported T types:
- Boolean - uses a logic of TryConvert(out bool)
- Number (
s/byte,u/short,u/int,u/long,float,double, ordecimal) - uses a logic of TryConvert(out double, CultureInfo) and succeeds, if the value fits into the target type. - String - sets the result to a text representation of a cell value (using current culture).
- DateTime - uses a logic of TryConvert(out DateTime)
- TimeSpan - uses a logic of TryConvert(out TimeSpan, CultureInfo)
- XLError - if the value is of type Error, it will return the value.
- Enum - tries to parse a value to a member by comparing the text of a cell value and a member name.
If the T is a nullable value type and the value of cell is blank or empty string, return null value.
If the cell value can't be determined because formula function is not implemented, the method always returns false.
T GetValue<T>()
Returns
- T
Type Parameters
TThe requested type into which will the value be converted.
Remarks
Conversion logic is identical with TryGetValue<T>(out T).
Exceptions
- InvalidCastException
If the value can't be converted to the type of T
InsertCellsAbove(int)
IXLCells InsertCellsAbove(int numberOfRows)
Parameters
numberOfRowsint
Returns
InsertCellsAfter(int)
IXLCells InsertCellsAfter(int numberOfColumns)
Parameters
numberOfColumnsint
Returns
InsertCellsBefore(int)
IXLCells InsertCellsBefore(int numberOfColumns)
Parameters
numberOfColumnsint
Returns
InsertCellsBelow(int)
IXLCells InsertCellsBelow(int numberOfRows)
Parameters
numberOfRowsint
Returns
InsertData(IEnumerable)
Inserts the IEnumerable data elements and returns the range it occupies.
IXLRange InsertData(IEnumerable data)
Parameters
dataIEnumerableThe IEnumerable data.
Returns
InsertData(IEnumerable, bool)
Inserts the IEnumerable data elements and returns the range it occupies.
IXLRange InsertData(IEnumerable data, bool transpose)
Parameters
dataIEnumerableThe IEnumerable data.
transposeboolif set to
truethe data will be transposed before inserting.
Returns
InsertData(DataTable)
Inserts the data of a data table.
IXLRange InsertData(DataTable dataTable)
Parameters
dataTableDataTableThe data table.
Returns
- IXLRange
The range occupied by the inserted data
InsertTable(DataTable)
Inserts the DataTable data elements as a table and returns it.
The new table will receive a generic name: Table#
IXLTable InsertTable(DataTable data)
Parameters
dataDataTableThe table data.
Returns
InsertTable(DataTable, bool)
Inserts the DataTable data elements as a table and returns it.
The new table will receive a generic name: Table#
IXLTable InsertTable(DataTable data, bool createTable)
Parameters
dataDataTableThe table data.
createTableboolif set to
trueit will create an Excel table.if set to
falsethe table will be created in memory.
Returns
InsertTable(DataTable, string)
Creates an Excel table from the given DataTable data elements.
IXLTable InsertTable(DataTable data, string tableName)
Parameters
Returns
InsertTable(DataTable, string, bool)
Inserts the DataTable data elements as a table and returns it.
IXLTable InsertTable(DataTable data, string tableName, bool createTable)
Parameters
dataDataTableThe table data.
tableNamestringName of the table.
createTableboolif set to
trueit will create an Excel table.if set to
falsethe table will be created in memory.
Returns
InsertTable<T>(IEnumerable<T>)
Inserts the IEnumerable data elements as a table and returns it.
The new table will receive a generic name: Table#
IXLTable InsertTable<T>(IEnumerable<T> data)
Parameters
dataIEnumerable<T>The table data.
Returns
Type Parameters
T
InsertTable<T>(IEnumerable<T>, bool)
Inserts the IEnumerable data elements as a table and returns it.
The new table will receive a generic name: Table#
IXLTable InsertTable<T>(IEnumerable<T> data, bool createTable)
Parameters
dataIEnumerable<T>The table data.
createTableboolif set to
trueit will create an Excel table.if set to
falsethe table will be created in memory.
Returns
Type Parameters
T
InsertTable<T>(IEnumerable<T>, string)
Creates an Excel table from the given IEnumerable data elements.
IXLTable InsertTable<T>(IEnumerable<T> data, string tableName)
Parameters
dataIEnumerable<T>The table data.
tableNamestringName of the table.
Returns
Type Parameters
T
InsertTable<T>(IEnumerable<T>, string, bool)
Inserts the IEnumerable data elements as a table and returns it.
IXLTable InsertTable<T>(IEnumerable<T> data, string tableName, bool createTable)
Parameters
dataIEnumerable<T>The table data.
tableNamestringName of the table.
createTableboolif set to
trueit will create an Excel table.if set to
falsethe table will be created in memory.
Returns
Type Parameters
T
InvalidateFormula()
Invalidate CachedValue so the formula will be re-evaluated next time Value is accessed. If cell does not contain formula nothing happens.
void InvalidateFormula()
IsEmpty()
bool IsEmpty()
Returns
IsEmpty(XLCellsUsedOptions)
bool IsEmpty(XLCellsUsedOptions options)
Parameters
optionsXLCellsUsedOptions
Returns
IsMerged()
bool IsMerged()
Returns
MergedRange()
IXLRange MergedRange()
Returns
Select()
void Select()
SetActive(bool)
IXLCell SetActive(bool value = true)
Parameters
valuebool
Returns
SetDataValidation()
[Obsolete("Use GetDataValidation to access the existing rule, or CreateDataValidation() to create a new one.")]
IXLDataValidation SetDataValidation()
Returns
SetFormulaA1(string)
IXLCell SetFormulaA1(string formula)
Parameters
formulastring
Returns
SetFormulaR1C1(string)
IXLCell SetFormulaR1C1(string formula)
Parameters
formulastring
Returns
SetHyperlink(XLHyperlink)
void SetHyperlink(XLHyperlink hyperlink)
Parameters
hyperlinkXLHyperlink
SetValue(XLCellValue)
Gets or sets the cell's value.
Getter will return value of a cell or value of formula. Getter will evaluate a formula, if the cell NeedsRecalculation, before returning up-to-date value.
Setter will clear a formula, if the cell contains a formula. If the value is a text that starts with a single quote, setter will prefix the value with a single quote through IncludeQuotePrefix in Excel too and the value of cell is set to to non-quoted text.
IXLCell SetValue(XLCellValue value)
Parameters
valueXLCellValue
Returns
- IXLCell
This cell.
TableCellType()
XLTableCellType TableCellType()
Returns
ToString(string)
Returns a string that represents the current state of the cell according to the format.
string ToString(string format)
Parameters
formatstringA: address, F: formula, NF: number format, BG: background color, FG: foreground color, V: formatted value
Returns
TryGetValue<T>(out T)
Try to get cell's value converted to the T type.
Supported T types:
- Boolean - uses a logic of TryConvert(out bool)
- Number (
s/byte,u/short,u/int,u/long,float,double, ordecimal) - uses a logic of TryConvert(out double, CultureInfo) and succeeds, if the value fits into the target type. - String - sets the result to a text representation of a cell value (using current culture).
- DateTime - uses a logic of TryConvert(out DateTime)
- TimeSpan - uses a logic of TryConvert(out TimeSpan, CultureInfo)
- XLError - if the value is of type Error, it will return the value.
- Enum - tries to parse a value to a member by comparing the text of a cell value and a member name.
If the T is a nullable value type and the value of cell is blank or empty string, return null value.
If the cell value can't be determined because formula function is not implemented, the method always returns false.
bool TryGetValue<T>(out T value)
Parameters
valueTValue to store the value.
Returns
- bool
trueif the value was converted and the result is in thevalue,falseotherwise.
Type Parameters
TThe requested type into which will the value be converted.
WorksheetColumn()
IXLColumn WorksheetColumn()
Returns
WorksheetRow()
IXLRow WorksheetRow()