Table of Contents

Interface IXLCell

Namespace
SlapKit.Excel.Excel
Assembly
SlapKit.Excel.dll
public interface IXLCell
Extension Methods

Properties

Active

bool Active { get; set; }

Property Value

bool

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

XLCellValue

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

IXLRangeAddress

HasArrayFormula

bool HasArrayFormula { get; }

Property Value

bool

HasComment

bool HasComment { get; }

Property Value

bool

HasDataValidation

bool HasDataValidation { get; }

Property Value

bool

HasFormula

bool HasFormula { get; }

Property Value

bool
bool HasHyperlink { get; }

Property Value

bool

HasRichText

bool HasRichText { get; }

Property Value

bool

HasSparkline

bool HasSparkline { get; }

Property Value

bool

NeedsRecalculation

Flag indicating that previously calculated cell value may be not valid anymore and has to be re-evaluated.

bool NeedsRecalculation { get; }

Property Value

bool

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

bool

Sparkline

IXLSparkline Sparkline { get; }

Property Value

IXLSparkline

Style

Gets or sets the cell's style.

IXLStyle Style { get; set; }

Property Value

IXLStyle

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

XLCellValue

Worksheet

IXLWorksheet Worksheet { get; }

Property Value

IXLWorksheet

Methods

AddConditionalFormat()

IXLConditionalFormat AddConditionalFormat()

Returns

IXLConditionalFormat

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

rangeName string

Name of the range.

Returns

IXLCell

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

rangeName string
scope XLScope

Returns

IXLCell

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

rangeName string
scope XLScope
comment string

Returns

IXLCell

AsRange()

Returns this cell as an IXLRange.

IXLRange AsRange()

Returns

IXLRange

CellAbove()

IXLCell CellAbove()

Returns

IXLCell

CellAbove(int)

IXLCell CellAbove(int step)

Parameters

step int

Returns

IXLCell

CellBelow()

IXLCell CellBelow()

Returns

IXLCell

CellBelow(int)

IXLCell CellBelow(int step)

Parameters

step int

Returns

IXLCell

CellLeft()

IXLCell CellLeft()

Returns

IXLCell

CellLeft(int)

IXLCell CellLeft(int step)

Parameters

step int

Returns

IXLCell

CellRight()

IXLCell CellRight()

Returns

IXLCell

CellRight(int)

IXLCell CellRight(int step)

Parameters

step int

Returns

IXLCell

Clear(XLClearOptions)

Clears the contents of this cell.

IXLCell Clear(XLClearOptions clearOptions = XLClearOptions.All)

Parameters

clearOptions XLClearOptions

Specify what you want to clear.

Returns

IXLCell

CopyFrom(IXLCell)

IXLCell CopyFrom(IXLCell otherCell)

Parameters

otherCell IXLCell

Returns

IXLCell

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

rangeBase IXLRangeBase

Range whose content to copy.

Returns

IXLCell

This cell.

CopyFrom(string)

IXLCell CopyFrom(string otherCell)

Parameters

otherCell string

Returns

IXLCell

CopyTo(IXLCell)

IXLCell CopyTo(IXLCell target)

Parameters

target IXLCell

Returns

IXLCell

CopyTo(string)

IXLCell CopyTo(string target)

Parameters

target string

Returns

IXLCell

CreateComment()

Creates a new comment for the cell, replacing the existing one.

IXLComment CreateComment()

Returns

IXLComment

CreateDataValidation()

Creates a new data validation rule for the cell, replacing the existing one.

IXLDataValidation CreateDataValidation()

Returns

IXLDataValidation

Creates a new hyperlink replacing the existing one.

XLHyperlink CreateHyperlink()

Returns

XLHyperlink

CreateRichText()

Replaces a value of the cell with a newly created rich text object.

IXLRichText CreateRichText()

Returns

IXLRichText

Delete(XLShiftDeletedCells)

Deletes the current cell and shifts the surrounding cells according to the shiftDeleteCells parameter.

void Delete(XLShiftDeletedCells shiftDeleteCells)

Parameters

shiftDeleteCells XLShiftDeletedCells

How to shift the surrounding cells.

GetBoolean()

Gets the cell's value as a Boolean.

bool GetBoolean()

Returns

bool

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

IXLComment

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

IXLDataValidation

GetDateTime()

Gets the cell's value as a DateTime.

DateTime GetDateTime()

Returns

DateTime

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

double

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

XLError

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

string

Returns a hyperlink for the cell, if any, or creates a new instance is there is no hyperlink.

XLHyperlink GetHyperlink()

Returns

XLHyperlink

GetRichText()

Returns the value of the cell if it formatted as a rich text.

IXLRichText GetRichText()

Returns

IXLRichText

GetString()

Return cell's value represented as a string. Doesn't use cell's formatting or style.

string GetString()

Returns

string

GetText()

Gets the cell's value as a String.

string GetText()

Returns

string

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

TimeSpan

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:

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

T

The 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

numberOfRows int

Returns

IXLCells

InsertCellsAfter(int)

IXLCells InsertCellsAfter(int numberOfColumns)

Parameters

numberOfColumns int

Returns

IXLCells

InsertCellsBefore(int)

IXLCells InsertCellsBefore(int numberOfColumns)

Parameters

numberOfColumns int

Returns

IXLCells

InsertCellsBelow(int)

IXLCells InsertCellsBelow(int numberOfRows)

Parameters

numberOfRows int

Returns

IXLCells

InsertData(IEnumerable)

Inserts the IEnumerable data elements and returns the range it occupies.

IXLRange InsertData(IEnumerable data)

Parameters

data IEnumerable

The IEnumerable data.

Returns

IXLRange

InsertData(IEnumerable, bool)

Inserts the IEnumerable data elements and returns the range it occupies.

IXLRange InsertData(IEnumerable data, bool transpose)

Parameters

data IEnumerable

The IEnumerable data.

transpose bool

if set to true the data will be transposed before inserting.

Returns

IXLRange

InsertData(DataTable)

Inserts the data of a data table.

IXLRange InsertData(DataTable dataTable)

Parameters

dataTable DataTable

The 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

data DataTable

The table data.

Returns

IXLTable

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

data DataTable

The table data.

createTable bool

if set to true it will create an Excel table.

if set to false the table will be created in memory.

Returns

IXLTable

InsertTable(DataTable, string)

Creates an Excel table from the given DataTable data elements.

IXLTable InsertTable(DataTable data, string tableName)

Parameters

data DataTable

The table data.

tableName string

Name of the table.

Returns

IXLTable

InsertTable(DataTable, string, bool)

Inserts the DataTable data elements as a table and returns it.

IXLTable InsertTable(DataTable data, string tableName, bool createTable)

Parameters

data DataTable

The table data.

tableName string

Name of the table.

createTable bool

if set to true it will create an Excel table.

if set to false the table will be created in memory.

Returns

IXLTable

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

data IEnumerable<T>

The table data.

Returns

IXLTable

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

data IEnumerable<T>

The table data.

createTable bool

if set to true it will create an Excel table.

if set to false the table will be created in memory.

Returns

IXLTable

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

data IEnumerable<T>

The table data.

tableName string

Name of the table.

Returns

IXLTable

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

data IEnumerable<T>

The table data.

tableName string

Name of the table.

createTable bool

if set to true it will create an Excel table.

if set to false the table will be created in memory.

Returns

IXLTable

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

bool

IsEmpty(XLCellsUsedOptions)

bool IsEmpty(XLCellsUsedOptions options)

Parameters

options XLCellsUsedOptions

Returns

bool

IsMerged()

bool IsMerged()

Returns

bool

MergedRange()

IXLRange MergedRange()

Returns

IXLRange

Select()

void Select()

SetActive(bool)

IXLCell SetActive(bool value = true)

Parameters

value bool

Returns

IXLCell

SetDataValidation()

[Obsolete("Use GetDataValidation to access the existing rule, or CreateDataValidation() to create a new one.")]
IXLDataValidation SetDataValidation()

Returns

IXLDataValidation

SetFormulaA1(string)

IXLCell SetFormulaA1(string formula)

Parameters

formula string

Returns

IXLCell

SetFormulaR1C1(string)

IXLCell SetFormulaR1C1(string formula)

Parameters

formula string

Returns

IXLCell
void SetHyperlink(XLHyperlink hyperlink)

Parameters

hyperlink XLHyperlink

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

value XLCellValue

Returns

IXLCell

This cell.

TableCellType()

XLTableCellType TableCellType()

Returns

XLTableCellType

ToString(string)

Returns a string that represents the current state of the cell according to the format.

string ToString(string format)

Parameters

format string

A: address, F: formula, NF: number format, BG: background color, FG: foreground color, V: formatted value

Returns

string

TryGetValue<T>(out T)

Try to get cell's value converted to the T type.

Supported T types:

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

value T

Value to store the value.

Returns

bool

true if the value was converted and the result is in the value, false otherwise.

Type Parameters

T

The requested type into which will the value be converted.

WorksheetColumn()

IXLColumn WorksheetColumn()

Returns

IXLColumn

WorksheetRow()

IXLRow WorksheetRow()

Returns

IXLRow