Spread 8.0 Documentation
Example
Support Options

Glossary Item Box

Example


The following example adds data to the first sheet, then in a command button sets the sheet to print centered vertically and horizontally on the printed page.

C++

BOOL CAboutDlg::OnInitDialog()
{
    CDialog::OnInitDialog();
    int i;
    int j;
    // Add data
    m_Spread.SetSheetCount(2);
    m_Spread.SetSheet(1);
    m_Spread.SetMaxCols(10);
    m_Spread.SetMaxRows(30);

    for (i=1; i<11; i++)
    {
        for (j=1; j<31; j++)
        {
            m_Spread.SetCol(i);
            m_Spread.SetRow(j);
            m_Spread.SetText("test");
        }
    }
}

void CAboutDlg::OnOK()
{
    // Set the sheet to print
    m_Spread.SetSheet(1);
    // Center vertically
    m_Spread.SetPrintCenterOnPageV(true);
    // Center horizontally
    m_Spread.SetPrintCenterOnPageH(true);
    // Print
    m_Spread.PrintSheet(0);
}

Visual Basic

Private Sub Form_Load()
    ' Create data
    Dim i As Integer
    Dim j As Integer
    fpSpread1.SheetCount = 2
    fpSpread1.Sheet = 1
    fpSpread1.MaxCols = 10
    fpSpread1.MaxRows = 20
    For i = 1 To 10
        For j = 1 To 20
            fpSpread1.Col = i
            fpSpread1.Row = j
            fpSpread1.Text = i & j
        Next j
    Next i
End Sub

Private Sub Command1_Click()
    ' Print first sheet
    fpSpread1.Sheet = 1
    ' Center vertically
    fpSpread1.PrintCenterOnPageV = True
    ' Center horizontally
    fpSpread1.PrintCenterOnPageH = True
    ' Print
    fpSpread1.PrintSheet 0
End Sub

Copyright © GrapeCity, inc. All rights reserved.