GemBox.Spreadsheet

ExcelWorksheet Class

Excel worksheet is a table with additional properties, identified by a unique name.

For a list of all members of this type, see ExcelWorksheet Members.

System.Object
   GemBox.Spreadsheet.ExcelWorksheet

public sealed class ExcelWorksheet

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

Remarks

Worksheet in Microsoft Excel has limited size. Number of rows (ExcelRow) is limited to ExcelFile.MaxRows. Number of columns (ExcelColumn) is limited to ExcelFile.MaxColumns. A specific cell (ExcelCell) can be accessed either trough ExcelRow.Cells, ExcelColumn.Cells or ExcelWorksheet.Cells property. Whichever property used, there are two distinct methods of getting a cell reference; using name and using index. For example, full name of cell in top left corner of a worksheet is "A1". Translated to indexes, same cell would be 0,0 (zero row and zero column). If using ExcelRow.Cells or ExcelColumn.Cells to access a specific cell, only partial name or partial index must be used, providing unknown column or row information.

Example

Look at following code for cell referencing examples:

[Visual Basic]
    Dim ws As ExcelWorksheet = excelFile.Worksheets.ActiveWorksheet

    ws.Cells("B2").Value = "Cell B2."
    ws.Cells(6, 0).Value = "Cell in row 7 and column A."

    ws.Rows(2).Cells(0).Value = "Cell in row 3 and column A."
    ws.Rows("4").Cells("B").Value = "Cell in row 4 and column B."

    ws.Columns(2).Cells(4).Value = "Cell in column C and row 5."
    ws.Columns("AA").Cells("6").Value = "Cell in AA column and row 6."
[C#]
    ExcelWorksheet ws = excelFile.Worksheets.ActiveWorksheet;

    ws.Cells["B2"].Value = "Cell B2.";
    ws.Cells[6,0].Value = "Cell in row 7 and column A.";

    ws.Rows[2].Cells[0].Value = "Cell in row 3 and column A.";
    ws.Rows["4"].Cells["B"].Value = "Cell in row 4 and column B.";

    ws.Columns[2].Cells[4].Value = "Cell in column C and row 5.";
    ws.Columns["AA"].Cells["6"].Value = "Cell in AA column and row 6.";

Requirements

Namespace: GemBox.Spreadsheet

Assembly: GemBox.Spreadsheet (in GemBox.Spreadsheet.dll)

See Also

ExcelWorksheet Members | GemBox.Spreadsheet Namespace | ExcelRow | ExcelColumn | ExcelCell