Spread Windows Forms 17
Spread Windows Forms 17.0 Product Documentation / Developer's Guide / Sheets / Working with 1-Based Indexing
In This Topic
    Working with 1-Based Indexing
    In This Topic

    Spread for WinForms provides extensive support for adding one or more worksheets with 1-based indexing in a workbook. This type of indexing facilitates effective conversion of SpreadCom or Excel VBA to new APIs. Users can add worksheets with 1-based indexing with the help of some wrapper classes. These classes allow users to convert the indexed parameters and forward them to the old implementation. 

    By default, each workbook possesses a single worksheet named Sheet 1 with sheet index 0.

    Inserting worksheets with 1-based indexing is useful especially when the users don't intend to initiate the workbook with the default sheet index as 0 and also don't want the cells nomenclature to be started from zero (for instance - By default, the A1 cell is referenced as (0,0) but using 1-based indexing, the same cell will be referred as (1,1)). In such a scenario, 1-based indexing eliminates all the confusion with the nomenclature of the worksheets and the cells of the worksheet in a workbook. 

    Example

    This example code creates a wrapper class and shows how to add a sheet using 1-based indexing.

    C#
    Copy Code
    // CreateBase1Object Wrapper class to support 1 based indexing
    IWorkbook workbook = WorkbookSet.CreateBase1Object(fpSpread1.AsWorkbook());
    workbook.Worksheets[1].Cells[1, 1].Value = "Test";
    

    VB
    Copy Code
    'CreateBase1Object Wrapper class to support 1 based indexing
    Dim workbook As IWorkbook = WorkbookSet.CreateBase1Object(fpSpread1.AsWorkbook())
    workbook.Worksheets(1).Cells(1, 1).Value = "Test"
    

    Note: The LinkSources property uses zero-based indexing and not 1-based indexing because it is an array.