Spread 8.0 Documentation
Example
Support Options

Glossary Item Box

Example


The following example creates a workbook with two sheets and loads data in the first sheet. The user can click a button to preview the first sheet in the fpSpreadPreview control, and to print the first sheet.

C++

CDialog::OnInitDialog();

int i;
int j;
// Add data
m_Spread.SetSheetCount(2);
m_Spread.SetSheet(1);
m_Spread.SetMaxCols(10);
m_Spread.SetMaxRows(70);

for (i=1; i<11; i++)
{
    for (j=1; j<71; 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);
// Use preview to see how this will look
// Attach preview control to Spread
m_Preview.SetHWndSpread(m_Spread.GetHWnd());
// Print the sheet
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 = 70
For i = 1 To 10
    For j = 1 To 70
        fpSpread1.Col = i
        fpSpread1.Row = j
        fpSpread1.Text = i & j
    Next j
Next i
End Sub

Private Sub Command1_Click()
' Set the sheet to print
fpSpread1.Sheet = 1
' Use preview to see how this will look
fpSpreadPreview1.hWndSpread = fpSpread1.hWnd
' Print the sheet
fpSpread1.PrintSheet 0
End Sub

© 2002-2014 ComponentOne, a division of GrapeCity. All Rights Reserved.