ComponentOne Excel for .NET
Quick Start / Step 2 of 4: Adding Content to a C1XLBook
In This Topic
    Step 2 of 4: Adding Content to a C1XLBook
    In This Topic

    While you are still in code view in the Visual Studio project, add the following code within the Form_Load event created in Step 1 of 4. This code will add content to the Excel workbook.

    To write code in Visual Basic

    Visual Basic
    Copy Code
    ' Add content to the sheet.
    Dim i As Integer
    Dim sheet as XLSheet = C1XLBook1.Sheets(0)
    For i = 0 To 9
        sheet(i, 0).Value = (i + 1) * 10
        sheet(i, 1).Value = (i + 1) * 100
        sheet(i, 2).Value = (i + 1) * 1000
    Next i

    To write code in C#

    C#
    Copy Code
    // Add content to the sheet.
    int i;
    C1.C1Excel.XLSheet sheet = c1XLBook1.Sheets[0];
    for (i = 0; i <= 9; i++)
    {
       sheet[i, 0].Value = (i + 1) * 10;
       sheet[i, 1].Value = (i + 1) * 100;
       sheet[i, 2].Value = (i + 1) * 1000;
    }

    The first ten rows in the first three columns of the XLS file will be populated with numbers when you run the project.