Table of Contents

Class XlsName

Namespace
Spire.Xls.Core.Spreadsheet
Assembly
Spire.XLS.dll
public class XlsName : XlsObject, INamedRange, IXLSRange, IExcelApplication, IEnumerable, IDisposable
Inheritance
XlsName
Implements
Inherited Members

Properties

BooleanValue

Gets / sets boolean value that is contained by this range. The following code illustrates how to access Boolean property of the Range:

//Create worksheetWorkbook workbook = new Workbook();Worksheet worksheet = workbook.Worksheets[0];//Set and get BooleanValueworksheet.Range[2, 4].BooleanValue = true;bool boolean = worksheet.Range[2, 4].BooleanValue;
public bool BooleanValue { get; set; }

Property Value

bool

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). The following code illustrates how to access Borders property of the Range:

//Create worksheetWorkbook workbook = new Workbook();Worksheet worksheet = workbook.Worksheets[0];//Set textworksheet["C2"].Text = "Sample";//Set bordersIBorders borders = worksheet["C2"].Borders;//Set line styleborders[BordersLineType.EdgeTop].LineStyle = LineStyleType.Thin;borders[BordersLineType.EdgeBottom].LineStyle = LineStyleType.Thin;//Set border colorborders[BordersLineType.EdgeTop].Color = Color.Red;borders[BordersLineType.EdgeBottom].Color = Color.Red;//Save to fileworkbook.SaveToFile("CellFormats.xlsx");
public IBorders Borders { get; }

Property Value

IBorders

BuiltInStyle

Gets/sets built in style. The following code illustrates how to access BuiltInStyle property:

//Create worksheetWorkbook workbook = new Workbook();Worksheet worksheet = workbook.Worksheets[0];//Set textworksheet["C2"].Text = "Sample";//Set built in styleworksheet["C2"].BuiltInStyle = BuiltInStyles.Accent3;//Save to fileworkbook.SaveToFile("BuiltInStyle.xlsx");
public BuiltInStyles? BuiltInStyle { get; set; }

Property Value

BuiltInStyles?

CellList

Returns a Range object that represents the cells in the specified range. Read-only. The following code illustrates how to access CellList property of the Range:

//Create worksheetWorkbook workbook = new Workbook();Worksheet worksheet = workbook.Worksheets[0];//Set text. The content contained by ![CDATA[]] will be expressed as plain textListCellRange cells = worksheet["A1:E8"].CellList;//Do some manipulationsforeach (CellRange Range in cells)    Range.Text = Range.RangeAddressLocal;//Save to fileworkbook.SaveToFile("CellList.xlsx");
public List<CellRange> CellList { get; }

Property Value

List<CellRange>

CellStyleName

Returns name of the Style object that represents the style of the specified range. Read/write String. The following code illustrates how to access CellStyleName of the specified range:

//Create worksheetWorkbook workbook = new Workbook();Worksheet worksheet = workbook.Worksheets[0];//Add and set styleCellStyle style = workbook.Styles.Add("CustomStyle");worksheet["C2"].Style = style;//Check Style nameConsole.Write(worksheet["C2"].CellStyleName);
public string CellStyleName { get; set; }

Property Value

string

Cells

Returns a Range object that represents the cells in the specified range. Read-only.

[Obsolete("Please use CellList")]
public CellRange[] Cells { get; }

Property Value

CellRange[]

Column

Returns the number of the first column in the first area in the specified range. Read-only. The following code illustrates how to access Column property of the Range:

//Create worksheetWorkbook workbook = new Workbook();Worksheet worksheet = workbook.Worksheets[0];//Get specific columnint firstColumn = worksheet["E1:R3"].Column;
public int Column { get; }

Property Value

int

ColumnGroupLevel

Column group level. Read-only. -1 - Not all columns in the range have same group level. 0 - No grouping, 1 - 7 - Group level.

public int ColumnGroupLevel { get; }

Property Value

int

ColumnWidth

Returns or sets the width of all columns in the specified range. Read/write Double. The following code illustrates how to set the width of all columns in the specified range:

//Create worksheetWorkbook workbook = new Workbook();Worksheet worksheet = workbook.Worksheets[0];//Set the ColumnWidthworksheet["A1"].Text = "This cell contains sample text";worksheet["A1"].ColumnWidth = 25;//Save to fileworkbook.SaveToFile("ColumnWidth.xlsx");
public double ColumnWidth { get; set; }

Property Value

double

Columns

For a Range object, returns an array of Range objects that represent the columns in the specified range. The following code illustrates how to access columns:

//Create worksheetWorkbook workbook = new Workbook();Worksheet worksheet = workbook.Worksheets[0];//Set columnsIXLSRange[] columns = worksheet["A1:E8"].Columns;//Do some manipulationsforeach (IXLSRange column in columns)  column.Text = column.RangeAddressLocal;//Save to fileworkbook.SaveToFile("Columns.xlsx");
public IXLSRange[] Columns { get; }

Property Value

IXLSRange[]

Comment

Comment assigned to the range. Read-only. The following code illustrates how to access Comments property of the Range:

//Create worksheetWorkbook workbook = new Workbook();Worksheet worksheet = workbook.Worksheets[0];//Adding comments to a cellworksheet.Range["A1"].AddComment().Text = "Comments";//Add Rich Text CommentsCellRange range = worksheet.Range["A6"];range.AddComment().RichText.Text = "RichText";IRichTextString rtf = range.Comment.RichText;//Formatting first 4 charactersIFont redFont = workbook.CreateFont();redFont.IsBold = true;redFont.Color = Color.Red;rtf.SetFont(0, 3, redFont);//Save to fileworkbook.SaveToFile("DataValidation.xlsx");
public ICommentShape Comment { get; }

Property Value

ICommentShape

CommentValue

public string CommentValue { get; }

Property Value

string

ConditionalFormats

Collection of conditional formats.

public ConditionalFormats ConditionalFormats { get; }

Property Value

ConditionalFormats

Count

Returns the number of objects in the collection. Read-only.

public int Count { get; }

Property Value

int

DataValidation

Data validation for the range. The following code illustrates how to access DataValidation property of the Range:

//Create worksheetWorkbook workbook = new Workbook();Worksheet worksheet = workbook.Worksheets[0];//Data validation for numberIDataValidation validation = worksheet.Range["A3"].DataValidation;validation.AllowType = CellDataType.Integer;//Value between 0 to 10validation.CompareOperator = ValidationComparisonOperator.Between;validation.Formula1 = "0";validation.Formula2 = "10";//Save to fileworkbook.SaveToFile("DataValidation.xlsx");
public Validation DataValidation { get; }

Property Value

Validation

DateTimeValue

Gets / sets DateTime contained by this cell. Read-write DateTime. The following code illustrates how to set and access DateTimeValue property of the Range:

//Create worksheetWorkbook workbook = new Workbook();Worksheet worksheet = workbook.Worksheets[0];//Set and get the DateTimeValue of specified rangeworksheet.Range[2, 4].DateTimeValue = DateTime.Now;DateTime dateTime = worksheet.Range[2, 4].DateTimeValue;//Save to fileworkbook.SaveToFile("DateTimeValue.xlsx");
public DateTime DateTimeValue { get; set; }

Property Value

DateTime

EndCell

Returns a Range object that represents the cell at the end of the region that contains the source range.

public IXLSRange EndCell { get; }

Property Value

IXLSRange

EntireColumn

Returns a Range object that represents the entire column (or columns) that contains the specified range. Read-only.

public IXLSRange EntireColumn { get; }

Property Value

IXLSRange

EntireRow

Returns a Range object that represents the entire row (or rows) that contains the specified range. Read-only.

public IXLSRange EntireRow { get; }

Property Value

IXLSRange

EnvalutedValue

Returns the calculated value of a formula.

public string EnvalutedValue { get; }

Property Value

string

ErrorValue

Gets / sets error value that is contained by this range.

public string ErrorValue { get; set; }

Property Value

string

Formula

Returns or sets the object's formula in A1-style notation and in the language of the macro. Read/write Variant.

public string Formula { get; set; }

Property Value

string

FormulaArray

Represents array-entered formula. Visit http://www.cpearson.com/excel/array.htm for more information. The following code illustrates how to set and access FormulaArray property of the range:

//Create worksheetWorkbook workbook = new Workbook();Worksheet worksheet = workbook.Worksheets[0];//Assign array formulaworksheet.Range["A1:D1"].FormulaArray = "{1,2,3,4}";//Adding a named range for the range A1 to D1worksheet.Names.Add("ArrayRange", worksheet.Range["A1:D1"]);//Assign formula array with named rangeworksheet.Range["A2:D2"].FormulaArray = "ArrayRange+100";//Save to fileworkbook.SaveToFile("FormulaArray.xlsx");
public string FormulaArray { get; set; }

Property Value

string

FormulaArrayR1C1

Returns or sets the formula array for the range, using R1C1-style notation.

public string FormulaArrayR1C1 { get; set; }

Property Value

string

FormulaBoolValue

Returns the calculated value of the formula as a boolean.

public bool FormulaBoolValue { get; set; }

Property Value

bool

FormulaDateTime

Get / set formula DateTime value contained by this cell. DateTime.MinValue if not all cells of the range have same DateTime value.

public DateTime FormulaDateTime { get; set; }

Property Value

DateTime

FormulaErrorValue

Returns the calculated value of the formula as a string.

public string FormulaErrorValue { get; set; }

Property Value

string

FormulaNumberValue

Gets / sets number value evaluated by formula.

public double FormulaNumberValue { get; set; }

Property Value

double

FormulaR1C1

Returns or sets the formula for the range, using R1C1-style notation.

public string FormulaR1C1 { get; set; }

Property Value

string

FormulaStringValue

Gets / sets string value evaluated by formula.

public string FormulaStringValue { get; set; }

Property Value

string

HasBoolean

Indicates whether range contains bool value. Read-only. The following code illustrates how to set and access HasBoolean property of the Range:

//Create worksheetWorkbook workbook = new Workbook();Worksheet worksheet = workbook.Worksheets[0];//Assigning Value2 property of the Rangeworksheet["A3"].Value2 = false;//Checking Range typesbool isboolean = worksheet["A3"].HasBoolean;//Save to fileworkbook.SaveToFile("HasBoolean.xlsx");
public bool HasBoolean { get; }

Property Value

bool

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.

public bool HasDataValidation { get; }

Property Value

bool

HasDateTime

Indicates whether range contains DateTime value. Read-only. The following code illustrates how to set and access HasDateTime property of the Range:

//Create worksheetWorkbook workbook = new Workbook();Worksheet worksheet = workbook.Worksheets[0];//Assigning Value2 property of the Rangeworksheet["A1"].Value2 = DateTime.Now;//Checking Range typesbool isDateTime =  worksheet["A1"].HasDateTime;//Save to fileworkbook.SaveToFile("HasDateTime.xlsx");
public bool HasDateTime { get; }

Property Value

bool

HasError

Indicates whether range contains error value.

public bool HasError { get; }

Property Value

bool

HasExternalFormula

Indicates is current range has external formula. Read-only.

public bool HasExternalFormula { get; }

Property Value

bool

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.

public bool HasFormula { get; }

Property Value

bool

HasFormulaArray

Indicates whether range contains array-entered formula. Read-only.

public bool HasFormulaArray { get; }

Property Value

bool

HasFormulaBoolValue

Indicates if current range has formula bool value. Read only.

public bool HasFormulaBoolValue { get; }

Property Value

bool

HasFormulaDateTime

Indicates if current range has formula value formatted as DateTime. Read-only.

public bool HasFormulaDateTime { get; }

Property Value

bool

HasFormulaErrorValue

Indicates if current range has formula error value. Read only.

public bool HasFormulaErrorValue { get; }

Property Value

bool

HasFormulaNumberValue

Indicates if the current range has formula number value. Read-only.

public bool HasFormulaNumberValue { get; }

Property Value

bool

HasFormulaStringValue

Indicates if the current range has formula string value. Read-only.

public bool HasFormulaStringValue { get; }

Property Value

bool

HasMerged

Indicates whether this range is part of merged range. Read-only. The following code illustrates how to access HasMerged property:

//Create worksheetWorkbook workbook = new Workbook();Worksheet worksheet = workbook.Worksheets[0];//Set textworksheet["A1"].Text = "Sample text in cell";//Set mergeworksheet["A1:B1"].Merge();//Check mergeConsole.Write(worksheet["A1:B1"].HasMerged);
public bool HasMerged { get; }

Property Value

bool

HasNumber

Indicates whether the range contains number. Read-only. The following code illustrates how to set and access Value2 property of the Range:

//Create worksheetWorkbook workbook = new Workbook();Worksheet worksheet = workbook.Worksheets[0];//Assigning Value2 property of the Rangeworksheet["A2"].Value2 = 45;//Checking Range typesbool isNumber =  worksheet["A2"].HasNumber;//Save to fileworkbook.SaveToFile("HasNumber.xlsx");
public bool HasNumber { get; }

Property Value

bool

HasRichText

Indicates whether cell contains formatted rich text string. The following code illustrates how to access HasRichText property:

//Create worksheetWorkbook workbook = new Workbook();Worksheet worksheet = workbook.Worksheets[0];//Create styleIStyle style = workbook.Styles.Add("CustomStyle");//Set rich textIRichTextString richText = worksheet["C2"].RichText;richText.Text = "Sample";IFont font = style.Font;font.Color = Color.Red;richText.SetFont(0, 5, font);//Check HasRichTextConsole.Write(worksheet["C2"].HasRichText);//Save to fileworkbook.SaveToFile("HasRichText.xlsx");
public bool HasRichText { get; }

Property Value

bool

HasString

Indicates whether the range contains String. Read-only.

public bool HasString { get; }

Property Value

bool

HasStyle

Indicates whether range has default style. False means default style. Read-only. The following code illustrates how to access HasStyle property:

//Create worksheetWorkbook workbook = new Workbook();Worksheet worksheet = workbook.Worksheets[0];//Add styleCellStyle style = workbook.Styles.Add("CustomStyle");//Set color and stylestyle.Color = Color.Red;worksheet["C2"].Style = style;//Check HasStyleConsole.Write(worksheet["C2"].HasStyle);//Save to fileworkbook.SaveToFile("HasStyle.xlsx");
public bool HasStyle { get; }

Property Value

bool

HorizontalAlignment

Returns or sets the horizontal alignment for the specified object. Read/write HorizontalAlignType. The following code illustrates how to set alignment type:

//Create worksheetWorkbook workbook = new Workbook();Worksheet worksheet = workbook.Worksheets[0];//Set textworksheet["A1"].Text = "Test";//Set alignmentworksheet["A1"].HorizontalAlignment = HorizontalAlignType.Right;//Save to fileworkbook.SaveToFile("HorizontalAlignment.xlsx");
public HorizontalAlignType HorizontalAlignment { get; set; }

Property Value

HorizontalAlignType

HtmlString

Gets and sets the html string which contains data and some formattings in this cell.

public string HtmlString { get; set; }

Property Value

string

Returns hyperlinks for this range.

public IHyperLinks Hyperlinks { get; }

Property Value

IHyperLinks

IgnoreErrorOptions

Represents ignore error options. If not single cell returs concatenateed flags.

public IgnoreErrorType IgnoreErrorOptions { get; set; }

Property Value

IgnoreErrorType

IndentLevel

Returns or sets the indent level for the cell or range. Can be an integer from 0 to 15. Read/write Integer. The following code illustrates how to set indent level for a cell:

//Create worksheetWorkbook workbook = new Workbook();Worksheet worksheet = workbook.Worksheets[0];//Set textworksheet["C2"].Text = "Sample";//Set indent levelworksheet["C2"].IndentLevel = 2;//Save to fileworkbook.SaveToFile("IndentLevel.xlsx");
public int IndentLevel { get; set; }

Property Value

int

Index

public int Index { get; }

Property Value

int

IsBlank

Indicates whether the range is blank. Read-only.

public bool IsBlank { get; }

Property Value

bool

IsBuiltIn

public bool IsBuiltIn { get; set; }

Property Value

bool

IsExternName

[Obsolete("get and set are not implemented")]
public bool IsExternName { get; }

Property Value

bool

IsFormulaHidden

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.

public bool IsFormulaHidden { get; set; }

Property Value

bool

IsFunction

public bool IsFunction { get; set; }

Property Value

bool

IsGroupedByColumn

Indicates whether this range is grouped by column. Read-only.

public bool IsGroupedByColumn { get; }

Property Value

bool

IsGroupedByRow

Indicates whether this range is grouped by row. Read-only.

public bool IsGroupedByRow { get; }

Property Value

bool

IsInitialized

Indicates whether cell is initialized. Read-only.

public bool IsInitialized { get; }

Property Value

bool

IsLocal

public bool IsLocal { get; }

Property Value

bool

IsStringsPreserved

Indicates whether all values in the range are preserved as strings.

public bool? IsStringsPreserved { get; set; }

Property Value

bool?

IsWrapText

True if Microsoft Excel wraps the text in the object. Read/write Boolean. The following code illustrates how to access WrapText property:

//Create worksheetWorkbook workbook = new Workbook();Worksheet worksheet = workbook.Worksheets[0];//Set textworksheet["A1"].Text = "This cell contains sample text";//Set wrap textworksheet["A1"].IsWrapText = true;//Save to fileworkbook.SaveToFile("IsWrapText.xlsx");
public bool IsWrapText { get; set; }

Property Value

bool

this[int, int]

Gets / sets cell by row and column index. Row and column indexes are one-based.

public IXLSRange this[int row, int column] { get; set; }

Parameters

row int
column int

Property Value

IXLSRange

this[int, int, int, int]

Get cell range. Row and column indexes are one-based. Read-only.

public IXLSRange this[int row, int column, int lastRow, int lastColumn] { get; }

Parameters

row int
column int
lastRow int
lastColumn int

Property Value

IXLSRange

this[string]

Get cell range. Read-only.

public IXLSRange this[string name] { get; }

Parameters

name string

Property Value

IXLSRange

this[string, bool]

Gets cell range. Read-only.

public IXLSRange this[string name, bool IsR1C1Notation] { get; }

Parameters

name string
IsR1C1Notation bool

Property Value

IXLSRange

LastColumn

Returns last column of the range. Read-only.

public int LastColumn { get; set; }

Property Value

int

LastRow

Returns last row of the range. Read-only.

public int LastRow { get; set; }

Property Value

int

MergeArea

Returns a Range object that represents the merged range containing the specified cell. If the specified cell is not in a merged range, this property returns NULL. Read-only. The following code illustrates how to access MergeArea property:

//Create worksheetWorkbook workbook = new Workbook();Worksheet worksheet = workbook.Worksheets[0];//Set textworksheet["C2"].Text = "Sample text in cell";//Set mergeworksheet["C2:D3"].Merge();//Check merge areaConsole.Write(worksheet["C2"].MergeArea.AddressLocal);
public IXLSRange MergeArea { get; }

Property Value

IXLSRange

Name

public string Name { get; set; }

Property Value

string

NameLocal

public string NameLocal { get; set; }

Property Value

string

NumberFormat

Format of current cell. Analog of Style.NumberFormat property. The following code illustrates how to set NumberFormat property:

//Create worksheetWorkbook workbook = new Workbook();Worksheet worksheet = workbook.Worksheets[0];//Set dataworksheet["C2"].Value = "3100.23";//Set number formatworksheet["C2"].NumberFormat = "#,##1.##";//Save to fileworkbook.SaveToFile("NumberFormat.xlsx");
public string NumberFormat { get; set; }

Property Value

string

NumberText

Returns cell value after number format application. Read-only. The following code illustrates how to access NumberText property of the Range:

//Create worksheetWorkbook workbook = new Workbook();Worksheet worksheet = workbook.Worksheets[0];//Gets cell value with its number formatCellRange range= worksheet.Range[3, 1];range.Value = "1/1/2015";range.NumberFormat = "dd-MMM-yyyy";string numberText = range.NumberText;//Save to fileworkbook.SaveToFile("NumberText.xlsx");
public string NumberText { get; }

Property Value

string

NumberValue

Gets / sets double value of the range.

public double NumberValue { get; set; }

Property Value

double

RangeAddress

Returns the range reference in the language of the macro. Read-only String. The following code illustrates how to access Address property of the Range:

//Create worksheetWorkbook workbook = new Workbook();Worksheet worksheet = workbook.Worksheets[0];//Get RangeAddressstring address = worksheet.Range[3, 4].RangeAddress;
public string RangeAddress { get; }

Property Value

string

RangeAddressLocal

Returns the range reference for the specified range in the language of the user. Read-only String. The following code illustrates how to access AddressLocal property of the Range:

//Create worksheetWorkbook workbook = new Workbook();Worksheet worksheet = workbook.Worksheets[0];//Get RangeAddressLocalstring address = worksheet.Range[3, 4].RangeAddressLocal;
public string RangeAddressLocal { get; }

Property Value

string

RangeGlobalAddress

Returns range Address in format "'Sheet1'!$A$1". The following code illustrates how to access AddressGlobal property of the Range:

//Create worksheetWorkbook workbook = new Workbook();Worksheet worksheet = workbook.Worksheets[0];//Get RangeAddressstring address = worksheet.Range[3, 4].RangeGlobalAddress;
public string RangeGlobalAddress { get; }

Property Value

string

RangeGlobalAddress2007

public string RangeGlobalAddress2007 { get; }

Property Value

string

RangeR1C1Address

Returns the range reference using R1C1 notation. Read-only String. The following code illustrates how to access AddressR1C1 property of the Range:

//Create worksheetWorkbook workbook = new Workbook();Worksheet worksheet = workbook.Worksheets[0];//Get RangeR1C1Addressstring address = worksheet.Range[3, 4].RangeR1C1Address;
public string RangeR1C1Address { get; }

Property Value

string

RangeR1C1AddressLocal

Returns the range reference using R1C1 notation. Read-only String. The following code illustrates how to access AddressR1C1Local property of the Range:

//Create worksheetWorkbook workbook = new Workbook();Worksheet worksheet = workbook.Worksheets[0];//Get RangeR1C1AddressLocalstring address = worksheet.Range[3, 4].RangeR1C1Address;
public string RangeR1C1AddressLocal { get; }

Property Value

string

RefersToRange

public IXLSRange RefersToRange { get; set; }

Property Value

IXLSRange

RichText

String with rich text formatting. Read-only. The following code illustrates how to set rich text formatting in the range:

//Create worksheetWorkbook workbook = new Workbook();Worksheet worksheet = workbook.Worksheets[0];//Create styleIStyle style = workbook.Styles.Add("CustomStyle");//Set rich textIRichTextString richText = worksheet["C2"].RichText;richText.Text = "Sample text";//Set rich text fontIFont font = style.Font;font.IsBold = true;richText.SetFont(0, 5, font);//Save to fileworkbook.SaveToFile("RichText.xlsx");
public IRichTextString RichText { get; }

Property Value

IRichTextString

Row

Returns the number of the first row of the first area in the range. Read-only Long.

public int Row { get; }

Property Value

int

RowGroupLevel

Row group level. Read-only. -1 - Not all rows in the range have same group level. 0 - No grouping, 1 - 7 - Group level.

public int RowGroupLevel { get; }

Property Value

int

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. The following code illustrates how to set row height:

//Create worksheetWorkbook workbook = new Workbook();Worksheet worksheet = workbook.Worksheets[0];//Set textworksheet["A1"].Text = "Test";//Set row heightworksheet["A1"].RowHeight = 30;//Save to fileworkbook.SaveToFile("RowHeight.xlsx");
public double RowHeight { get; set; }

Property Value

double

Rows

For a Range object, returns an array of Range objects that represent the rows in the specified range. The following code illustrates how to access rows:

//Create worksheetWorkbook workbook = new Workbook();Worksheet worksheet = workbook.Worksheets[0];//Set rowsIXLSRange[] rows = worksheet["A1:E8"].Rows;//Do some manipulationsforeach (IXLSRange row in rows)  row.Text = row.RangeAddressLocal;//Save to fileworkbook.SaveToFile("Rows.xlsx");
public IXLSRange[] Rows { get; }

Property Value

IXLSRange[]

Scope

public string Scope { get; }

Property Value

string

Style

Returns a Style object that represents the style of the specified range. Read/write IStyle. The following code illustrates how to the style of the specified range:

//Create worksheetWorkbook workbook = new Workbook();Worksheet worksheet = workbook.Worksheets[0];//Set textworksheet["C2"].Text = "Sample";//Add and set styleCellStyle style = workbook.Styles.Add("BorderStyle");style.Color = Color.Red;worksheet["C2"].Style = style;//Save to fileworkbook.SaveToFile("Style.xlsx");
public IStyle Style { get; set; }

Property Value

IStyle

Text

Gets / sets string value of the range.

public string Text { get; set; }

Property Value

string

TimeSpanValue

Gets / sets time value of the range.

public TimeSpan TimeSpanValue { get; set; }

Property Value

TimeSpan

Value

public string Value { get; set; }

Property Value

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. The following code illustrates how to access Value2 property of the Range:

//Create worksheetWorkbook workbook = new Workbook();Worksheet worksheet = workbook.Worksheets[0];//Assigning Value2 property of the Rangeworksheet["A1"].Value2 = DateTime.Now;worksheet["A3"].Value2 = false;//Checking Range typesConsole.WriteLine(worksheet["A1"].HasDateTime);Console.WriteLine(worksheet["A3"].HasBoolean);
public object Value2 { get; set; }

Property Value

object

ValueR1C1

public string ValueR1C1 { get; }

Property Value

string

VerticalAlignment

Returns or sets the vertical alignment of the specified object. Read/write VerticalAlignType. The following code illustrates how to set vertical alignment type:

//Create worksheetWorkbook workbook = new Workbook();Worksheet worksheet = workbook.Worksheets[0];//Set textworksheet["A1"].Text = "Test";//Set alignmentworksheet["A1"].VerticalAlignment = VerticalAlignType.Top;//Save to fileworkbook.SaveToFile("VerticalAlignment.xlsx");
public VerticalAlignType VerticalAlignment { get; set; }

Property Value

VerticalAlignType

Visible

public bool Visible { get; set; }

Property Value

bool

Worksheet

public IWorksheet Worksheet { get; }

Property Value

IWorksheet

Methods

Activate()

public IXLSRange Activate()

Returns

IXLSRange

Activate(bool)

public IXLSRange Activate(bool scroll)

Parameters

scroll bool

Returns

IXLSRange

AddComment()

public ICommentShape AddComment()

Returns

ICommentShape

AutoFitColumns()

Autofits all columns in the range. The following code illustrates how to auto-size column width to its cell content:

//Create worksheetWorkbook workbook = new Workbook();Worksheet worksheet = workbook.Worksheets[0];//Auto-fit columnsworksheet.Range["B4"].Text = "Fit the content to column";worksheet.Range["B4"].AutoFitColumns();//Save to fileworkbook.SaveToFile("AutoFitRows.xlsx");
public void AutoFitColumns()

AutoFitRows()

Autofits all rows in the range. The following code illustrates how to auto-size row height to its cell content:

//Create worksheetWorkbook workbook = new Workbook();Worksheet worksheet = workbook.Worksheets[0];//Auto-fit rowsworksheet.Range["A2"].Text = "Fit the content to row";worksheet.Range["A2"].IsWrapText = true;worksheet.Range["A2"].AutoFitRows();//Save to fileworkbook.SaveToFile("AutoFitRows.xlsx");
public void AutoFitRows()

BorderAround()

Sets around border for current range. The following code illustrates how to apply border around the Range:

//Create worksheetWorkbook workbook = new Workbook();Worksheet worksheet = workbook.Worksheets[0];//Set textworksheet["C2"].Text = "Sample";worksheet["D2"].Text = "text";worksheet["C3"].Text = "in";worksheet["D3"].Text = "cell";//Set borderworksheet["C2:D3"].BorderAround();//Save to fileworkbook.SaveToFile("BorderAround.xlsx");
public void BorderAround()

BorderAround(LineStyleType)

public void BorderAround(LineStyleType borderLine)

Parameters

borderLine LineStyleType

BorderAround(LineStyleType, ExcelColors)

public void BorderAround(LineStyleType borderLine, ExcelColors borderColor)

Parameters

borderLine LineStyleType
borderColor ExcelColors

BorderAround(LineStyleType, Color)

public void BorderAround(LineStyleType borderLine, Color borderColor)

Parameters

borderLine LineStyleType
borderColor Color

BorderInside()

Sets inside border for current range. The following code illustrates how to apply border inside the Range:

//Create worksheetWorkbook workbook = new Workbook();Worksheet worksheet = workbook.Worksheets[0];//Set textworksheet["C2"].Text = "Sample";worksheet["D2"].Text = "text";worksheet["C3"].Text = "in";worksheet["D3"].Text = "cell";//Set borderworksheet["C2:D3"].BorderInside();//Save to fileworkbook.SaveToFile("BorderInside.xlsx");
public void BorderInside()

BorderInside(LineStyleType)

public void BorderInside(LineStyleType borderLine)

Parameters

borderLine LineStyleType

BorderInside(LineStyleType, ExcelColors)

public void BorderInside(LineStyleType borderLine, ExcelColors borderColor)

Parameters

borderLine LineStyleType
borderColor ExcelColors

BorderInside(LineStyleType, Color)

public void BorderInside(LineStyleType borderLine, Color borderColor)

Parameters

borderLine LineStyleType
borderColor Color

BorderNone()

Sets none border for current range. The following code illustrates how to remove borders in the Range:

//Create worksheetWorkbook workbook = new Workbook();workbook.LoadFromFile("Sample.xlsx");Worksheet worksheet = workbook.Worksheets[0];//Remove bordersworksheet["C2"].BorderNone();//Save to fileworkbook.SaveToFile("BorderNone.xlsx");
public void BorderNone()

Clear(ExcelClearOptions)

public void Clear(ExcelClearOptions option)

Parameters

option ExcelClearOptions

Clear(bool)

public void Clear(bool isClearFormat)

Parameters

isClearFormat bool

ClearContents()

Clear the contents of the Range. The following code illustrates how to clear the Range:

//Create worksheetWorkbook workbook = new Workbook();workbook.LoadFromFile("Sample.xlsx");Worksheet worksheet = workbook.Worksheets[0];//Clears the Range C2worksheet.Range["C2"].ClearContents();//Save to fileworkbook.SaveToFile("ClearContents.xlsx");
public void ClearContents()

Clone(object)

public object Clone(object parent)

Parameters

parent object

Returns

object

Clone(object, Dictionary<string, string>, XlsWorkbook)

[Obsolete("the method is not implemented")]
public IXLSRange Clone(object parent, Dictionary<string, string> hashNewNames, XlsWorkbook book)

Parameters

parent object
hashNewNames Dictionary<string, string>
book XlsWorkbook

Returns

IXLSRange

CollapseGroup(GroupByType)

public void CollapseGroup(GroupByType groupBy)

Parameters

groupBy GroupByType

ConvertFullRowColumnName(ExcelVersion)

[Obsolete("the method is not implemented")]
public void ConvertFullRowColumnName(ExcelVersion version)

Parameters

version ExcelVersion

CopyTo(IXLSRange)

public IXLSRange CopyTo(IXLSRange destination)

Parameters

destination IXLSRange

Returns

IXLSRange

Delete()

public void Delete()

ExpandGroup(GroupByType)

public void ExpandGroup(GroupByType groupBy)

Parameters

groupBy GroupByType

ExpandGroup(GroupByType, ExpandCollapseFlags)

public void ExpandGroup(GroupByType groupBy, ExpandCollapseFlags flags)

Parameters

groupBy GroupByType
flags ExpandCollapseFlags

ExportDataTable(ExportTableOptions)

public DataTable ExportDataTable(ExportTableOptions options)

Parameters

options ExportTableOptions

Returns

DataTable

FindAll(bool)

public CellRange[] FindAll(bool findValue)

Parameters

findValue bool

Returns

CellRange[]

FindAll(DateTime)

public CellRange[] FindAll(DateTime findValue)

Parameters

findValue DateTime

Returns

CellRange[]

FindAll(double, FindType)

public CellRange[] FindAll(double findValue, FindType flags)

Parameters

findValue double
flags FindType

Returns

CellRange[]

FindAll(string, FindType)

public List<CellRange> FindAll(string findValue, FindType flags)

Parameters

findValue string
flags FindType

Returns

List<CellRange>

FindAll(TimeSpan)

public CellRange[] FindAll(TimeSpan findValue)

Parameters

findValue TimeSpan

Returns

CellRange[]

FindFirst(bool)

public IXLSRange FindFirst(bool findValue)

Parameters

findValue bool

Returns

IXLSRange

FindFirst(DateTime)

public IXLSRange FindFirst(DateTime findValue)

Parameters

findValue DateTime

Returns

IXLSRange

FindFirst(double, FindType)

public IXLSRange FindFirst(double findValue, FindType flags)

Parameters

findValue double
flags FindType

Returns

IXLSRange

FindFirst(string, FindType)

public IXLSRange FindFirst(string findValue, FindType flags)

Parameters

findValue string
flags FindType

Returns

IXLSRange

FindFirst(TimeSpan)

public IXLSRange FindFirst(TimeSpan findValue)

Parameters

findValue TimeSpan

Returns

IXLSRange

FreezePanes()

Freezes pane at the current range. The following code illustrates how to freeze a pane in the Range:

//Create worksheetWorkbook workbook = new Workbook();Worksheet worksheet = workbook.Worksheets[0];//Applying Freeze Pane to the sheet by specifying a cellworksheet.Range["B2"].FreezePanes();//Save to fileworkbook.SaveToFile("FreezePanes.xlsx");
public void FreezePanes()

GetEnumerator()

public IEnumerator GetEnumerator()

Returns

IEnumerator

Intersect(IXLSRange)

public IXLSRange Intersect(IXLSRange range)

Parameters

range IXLSRange

Returns

IXLSRange

Merge()

Creates a merged cell from the specified Range object. The following code illustrates how to merge the Range:

//Create worksheetWorkbook workbook = new Workbook();Worksheet worksheet = workbook.Worksheets[0];//Set textworksheet["A1"].Text = "Merged cell";//Merge cellsworksheet["A1:B1"].Merge();//Save to fileworkbook.SaveToFile("Merge.xlsx");
public void Merge()

Merge(IXLSRange)

public IXLSRange Merge(IXLSRange range)

Parameters

range IXLSRange

Returns

IXLSRange

Merge(bool)

public void Merge(bool clearCells)

Parameters

clearCells bool

SetIndex(int)

[Obsolete("the method is not implemented")]
public void SetIndex(int index)

Parameters

index int

SetIndex(int, bool)

[Obsolete("the method is not implemented")]
public void SetIndex(int index, bool bRaiseEvent)

Parameters

index int
bRaiseEvent bool

UnMerge()

Separates a merged area into individual cells. The following code illustrates how to UnMerge the merged cells:

//Create worksheetWorkbook workbook = new Workbook();Worksheet worksheet = workbook.Worksheets[0];//Set textworksheet["A1"].Text = "Merged cell";//Merge cellsworksheet["A1:B1"].Merge(true);//Unmerge cellsworksheet["A1:B1"].UnMerge();//Save to fileworkbook.SaveToFile("UnMerge.xlsx");
public void UnMerge()