Spread 8.0 Documentation
Example
Support Options

Glossary Item Box

Example


The following example sets a maximum number of columns and rows, provides text for the column and row headers, and sets the width of the row header. In addition, the sheet displays scroll bars only when the maximum number of rows or columns exceed the current view. The example provides a command button. When the user clicks the button, it inserts a column and row, and provides text for the new column and row headers.

C++

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

    // Set the maximum number of columns
    m_Spread1.SetMaxCols(3);
    // Provide text for the column headers
    // Specify clipping block
    m_Spread1.SetCol(1);
    m_Spread1.SetCol2(4);
    m_Spread1.SetRow(0);
    m_Spread1.SetRow2(0);
    // Clip data into the sheet
    m_Spread1.SetClip("Anne\tLinda\tSteve");
    // Set the maximum number of rows
    m_Spread1.SetMaxRows(5);
    // Provide text for the row headers
    // Specify clipping block
    m_Spread1.SetCol(0);
    m_Spread1.SetCol2(0);
    m_Spread1.SetRow(1);
    m_Spread1.SetRow2(5);
    // Clip data into the spreads
    m_Spread1.SetClip("North\n\rNorth West\n\rWest\n\rSouth\n\rEast");
    // Set the width of the row header
    m_Spread1.SetColWidth(0,10);
    // Display scroll bars only if needed
    m_Spread1.SetScrollBarExtMode(TRUE);
}

void CTestDlg::OnButton1()
{
    // Insert one column before a specified column
    // Increase the maximum number of columns by 1
    m_Spread1.SetMaxCols(m_Spread1.GetMaxCols() + 1);
    // Insert a column
    m_Spread1.InsertCols(m_Spread1.GetMaxCols() - 2, 1);

    // Provide text for the new column header
    // Specify the column header
    m_Spread1.SetCol(m_Spread1.GetMaxCols() - 2);
    m_Spread1.SetRow(0);
    // Specify new text
    m_Spread1.SetText("Joe");

    // Insert one row before the specified row
    // Increase the maximum number of rows by 1
    m_Spread1.SetMaxRows(m_Spread1.GetMaxRows() + 1);
    // Insert a row
    m_Spread1.InsertRows(m_Spread1.GetMaxRows() - 1, 1);

    // Provide text for the new row header
    // Specify the row header
    m_Spread1.SetCol(0);
    m_Spread1.SetRow(m_Spread1.GetMaxRows() - 1);
    // Specify new text
    m_Spread1.SetText("South East");
}

Visual Basic

Sub Form_Load()

    ' Set the maximum number of columns
    fpSpread1.MaxCols = 3

    ' Provide text for the column headers
    ' Specify clipping block
    fpSpread1.Col = 1
    fpSpread1.Col2 = 4
    fpSpread1.Row = 0
    fpSpread1.Row2 = 0
    ' Clip data into the sheet
    fpSpread1.Clip = "Anne" + Chr$(9) + "Linda" + Chr$(9) + "Steve"

    ' Set the maximum number of rows
    fpSpread1.MaxRows = 5

    ' Provide text for the row headers
    ' Specify clipping block
    fpSpread1.Col = 0
    fpSpread1.Col2 = 0
    fpSpread1.Row = 1
    fpSpread1.Row2 = 5
    ' Clip data into the sheet
    fpSpread1.Clip = "North" + Chr$(13) + "North West" + Chr$(13) + "West" + Chr$(13) + "South" + Chr$(13) + "East"

    ' Set the width of the row header
    fpSpread1.ColWidth(0) = 10
    ' Display scroll bars only if needed
    fpSpread1.ScrollBarExtMode = True
End Sub


Sub Command1_Click()

    ' Insert one column before a specified column
    ' Increase the maximum number of columns by 1
    fpSpread1.MaxCols = 4
    ' Insert a column
    fpSpread1.InsertCols 2, 1

    ' Provide text for the new column header
    ' Specify the column header
    fpSpread1.Col = 2
    fpSpread1.Row = 0
    ' Specify new text
    fpSpread1.Text = "Joe"
    ' Insert one row before the specified row
    ' Increase the maximum number of rows by 1
    fpSpread1.MaxRows = 6
    ' Insert a row
    fpSpread1.InsertRows 5, 1

    ' Provide text for the new row header
    ' Specify the row header
    fpSpread1.Col = 0
    fpSpread1.Row = 5
    ' Specify new text
    fpSpread1.Text = "South East"

End Sub

Copyright © GrapeCity, inc. All rights reserved.