Spread 8.0 Documentation
Example
Support Options

Glossary Item Box

Example


The following example creates a sheet with 20 rows and 20 columns, calculates the number of sheets required to print the sheet in the upper half of an 8.5" X 11" page, and then prints it.

C++

void COwnerPrintPageCountDlg::OnShowWindow(BOOL bShow, UINT nStatus)
{
    CDialog::OnShowWindow(bShow, nStatus);

    int i, j;
    for( i=1;i<=20;i++ )
    {
        for( j=1;j<=20;j++ )
        m_Spread.SetText(j,i,CComVariant(_T("FARPOINT")));
    }
}

void COwnerPrintPageCountDlg::OnButton1()
{
// These are 8.5" X 11" paper dimensions in TWIPS
long PaperWidth = 12240;
long PaperHeight = 15840;
short PageCount, i;
DOCINFO docinfo;
CPrintDialog dlg(FALSE);
dlg.GetDefaults();
HDC hdcPrinter = dlg.GetPrinterDC();

// Set up DOCINFO structure
memset(&docinfo, 0, sizeof(docinfo));
docinfo.cbSize = sizeof(docinfo);
docinfo.lpszDocName = _T("OwnerPrintPageCount");


// call StartDoc() to begin printing
StartDoc(hdcPrinter, &docinfo);
m_Spread.OwnerPrintPageCount((long)hdcPrinter, 1440, 1440, PaperWidth - 1440, PaperHeight / 2 - 1440, &PageCount);
for( i=1;i<=PageCount;i++ )
    {
    StartPage(hdcPrinter);
    m_Spread.OwnerPrintDraw((long)hdcPrinter, 1440, 1440, PaperWidth - 1440, PaperHeight / 2 - 1440, i);
    EndPage(hdcPrinter);
    }
EndDoc(hdcPrinter);
}

Visual Basic

Private Sub Command1_Click()
    ' These are 8.5" X 11" paper dimensions in TWIPS
    Const PaperWidth = 12240
    Const PaperHeight = 15840
    Dim PageCount As Integer
    Dim i As Integer

    Printer.Print
    Call fpSpread1.OwnerPrintPageCount(Printer.hDC, 1440, 1440, PaperWidth - 1440, PaperHeight / 2 - 1440, PageCount)
    For i = 1 To PageCount
        Call fpSpread1.OwnerPrintDraw(Printer.hDC, 1440, 1440, PaperWidth - 1440, PaperHeight / 2 - 1440, i)
        Printer.NewPage
    Next i
    Printer.EndDoc
End Sub

Private Sub Form_Load()
    Dim i As Integer
    Dim j As Integer

    For i = 1 To 20
        fpSpread1.Row = i
        For j = 1 To 20
            fpSpread1.Col = j
            fpSpread1.Text = "FARPOINT"
        Next j
    Next i
End Sub

Copyright © GrapeCity, inc. All rights reserved.