Click or drag to resize
CellRangeItem Property (String)
Gets excel cell with the specified full or partial name.

Namespace: GemBox.Spreadsheet
Assembly: GemBox.Spreadsheet (in GemBox.Spreadsheet.dll) Version: 39.3.30.1189
Syntax
public ExcelCell this[
	string contextName
] { get; }

Parameters

contextName
Type: SystemString
Full or partial name of the cell.

Property Value

Type: ExcelCell
Remarks

If IndexingMode is RangeIndexingMode.Rectangular full name of the cell must be used (for example; "A1", "D7", etc.).

If IndexingMode is RangeIndexingMode.Horizontal column name must be used (for example; "A", "D", etc.).

If IndexingMode is RangeIndexingMode.Vertical row name must be used (for example; "1", "7", etc.).

Examples

Following code creates horizontal, vertical and rectangular cell ranges and demonstrates how indexing works different in different context. SetBorders(MultipleBorders, SpreadsheetColor, LineStyle) method is used to mark outside borders of the rectangular range.

CellRange cr = excelFile.Worksheets[0].Rows[1].Cells;

cr[0].Value = cr.IndexingMode;
cr[3].Value = "D2";
cr["B"].Value = "B2";

cr = excelFile.Worksheets[0].Columns[4].Cells;

cr[0].Value = cr.IndexingMode;
cr[2].Value = "E3";
cr["5"].Value = "E5";

cr = excelFile.Worksheets[0].Cells.GetSubrange("F2", "J8");
cr.Style.Borders.SetBorders(MultipleBorders.Outside, SpreadsheetColor.FromName(ColorName.Blue), LineStyle.Dashed);

cr["I7"].Value = cr.IndexingMode;
cr[0, 0].Value = "F2";
cr["G3"].Value = "G3";
cr[5].Value = "F3"; // Cell range width is 5 (F G H I J).

cr = excelFile.Worksheets[0].Cells.GetSubrange("F10:J16"); // Using A1 notation.
cr.Style.Borders.SetBorders(MultipleBorders.Outside, SpreadsheetColor.FromName(ColorName.Blue), LineStyle.Dashed);

cr["I15"].Value = cr.IndexingMode;
cr[0].Value = "F10";
cr["F11"].Value = "F11";
See Also