ActiveReports 14 .NET Edition
GrapeCity.ActiveReports.Export.Excel Assembly / GrapeCity.SpreadBuilder Namespace / DDSheet Class / Cell Method
The zero-based row number of the cell.

The zero-based column number of the cell.

Example

In This Topic
    Cell Method
    In This Topic
    Returns the DDCell object for the specified row and column.
    Syntax
    'Declaration
     
    Public Function Cell( _
       ByVal iRow As Integer, _
       ByVal iColumn As Integer _
    ) As DDCell
    public DDCell Cell( 
       int iRow,
       int iColumn
    )

    Parameters

    iRow
    The zero-based row number of the cell.
    iColumn

    The zero-based column number of the cell.

    Return Value

    The DDCell object for the specified row and column.
    Remarks
    This function will throw an ArgumentOutOfRangeException if the specified iRow or iColumn is not in the valid range. The maximum iRow value is 65535. The maximum iColumn value is 255. The minimum value for both the iRow and iColumn argument is 0.
    Example
    private void btnSpread_Click(object sender, System.EventArgs e)
    {
        //Dimension a Workbook and add a sheet to its Sheets collection
        GrapeCity.SpreadBuilder.Workbook sb = new GrapeCity.SpreadBuilder.Workbook();
        sb.Sheets.AddNew();
        //Set up properties and values for columns, rows and cells as desired
        sb.Sheets[0].Name = "Customer Call List";
        sb.Sheets[0].Columns(0).Width = 2 * 1440;
        sb.Sheets[0].Columns(1).Width = 1440;
        sb.Sheets[0].Columns(2).Width = 1440;
        sb.Sheets[0].Rows(0).Height = 1440/4;
        //Header row
        sb.Sheets[0].Cell(0,0).SetValue("Company Name");
        sb.Sheets[0].Cell(0,0).FontBold = true;
        sb.Sheets[0].Cell(0,1).SetValue("Contact Name");
        sb.Sheets[0].Cell(0,1).FontBold = true;
        sb.Sheets[0].Cell(0,2).SetValue("Phone");
        sb.Sheets[0].Cell(0,2).FontBold = true;
        //First row of data
        sb.Sheets[0].Cell(1,0).SetValue("GrapeCity");
        sb.Sheets[0].Cell(1,1).SetValue("Mortimer");
        sb.Sheets[0].Cell(1,2).SetValue("(614) 895-3142");
    
        //Save the Workbook to an Excel file
        sb.Save (Application.StartupPath + @"\x.xls");
    
        MessageBox.Show("Your Spreadsheet, " + sb.Sheets[0].Columns(0).OwnerSheet.Name + ", has been saved to " + Application.StartupPath + "\\x.xls");
    }
    Private Sub btnSpread_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSpread.Click
        'Dimension a Workbook and add a sheet to its Sheets collection
        Dim sb As New GrapeCity.SpreadBuilder.Workbook
        sb.Sheets.AddNew()
            
        'Set up properties and values for columns, rows and cells as desired
        With sb.Sheets(0)
            .Name = "Customer Call List"
            .Columns(0).Width = 2 * 1440
            .Columns(1).Width = 1440
            .Columns(2).Width = 1440
            .Rows(0).Height = 1440 / 4
            'Header row
            .Cell(0, 0).SetValue("Company Name")
            .Cell(0, 0).FontBold = True
            .Cell(0, 1).SetValue("Contact Name")
            .Cell(0, 1).FontBold = True
            .Cell(0, 2).SetValue("Phone")
            .Cell(0, 2).FontBold = True
            'First row of data
            .Cell(1, 0).SetValue("GrapeCity")
            .Cell(1, 1).SetValue("Mortimer")
            .Cell(1, 2).SetValue("(614) 895-3142")
         End With
    
        'Save the Workbook to an Excel file
        sb.Save(Application.StartupPath & "\x.xls")
    
        MsgBox("Your Spreadsheet, " & sb.Sheets(0).Columns(0).OwnerSheet.Name & ", has been saved to " & Application.StartupPath & "\x.xls")
    End Sub
    See Also