Spread 8.0 Documentation
Example
Support Options

Glossary Item Box

Example


The following example provides text for the column headers and the first column, starts the row numbering at a specified number, sets columns as edit cells that allow multiple lines of text, and sets the row height and the column width to display all the text for specified columns and rows.

C++

// Set the maximum number of columns
m_Spread.SetMaxCols(4);

// Provide text for the column headers
// Specify clipping block
m_Spread.SetCol(1);
m_Spread.SetCol2(4);
m_Spread.SetRow(0);
m_Spread.SetRow2(0);
// Clip data into the sheet
m_Spread.SetClip("Red Maples\tEach\t\tYear End Inventory");

// Set columns 1 and 2 as edit cells and allow multiple lines of text
// Specify the cell block
m_Spread.SetCol(1);
m_Spread.SetCol2(2);
m_Spread.SetRow(-1);
m_Spread.SetRow2(-1);
m_Spread.SetBlockMode(TRUE);
// Set the cells as edit cells
m_Spread.SetCellType(CellTypeEdit);
// Allow multiple lines of text
m_Spread.SetTypeEditMultiLine(TRUE);
m_Spread.SetBlockMode(FALSE);

// Set the starting number for the row headers
m_Spread.SetStartingRowNumber(1996);
// Set the maximum number of rows
m_Spread.SetMaxRows(10);

// Provide text for the first column
// Define the variable
int i;
for(i = 1; i <= 10;i++){
    // Specify the cells
    m_Spread.SetCol(1);
    m_Spread.SetRow(i);
    // Provide text
    m_Spread.SetText("Beginning Inventory\Chr$(10)\Purchases Chr$(10)Sales");
}

// Set the width for specified columns
// Set the width for row headers
m_Spread.SetColWidth(0,5);
// Set the width for column 1
m_Spread.SetColWidth(1,15);
// Set the width for column 2
m_Spread.SetColWidth(2,7);
// Set the width for column 3
m_Spread.SetColWidth(3,0.3);
// Return the width of column 4
fWidth = m_Spread.GetMaxTextColWidth(4);
// Set the width of column 4 to the returned value
m_Spread.SetColWidth(4,fWidth);

// Set the height for all rows
// Return the height of row 1
fWidth = m_Spread.GetMaxTextRowHeight(1);
// Set the height of all columns to the returned value
m_Spread.SetRowHeight(-1,fWidth);
// Set the height for the column header
m_Spread.SetRowHeight(0,20);

// Set the grid lines to display as dotted lines
m_Spread.SetGridSolid(FALSE);

Visual Basic

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

' 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 = "Red Maples" + Chr$(9) + "Each" + Chr$(9) + Chr$(9) + "Year End Inventory"

' Set columns 1 and 2 as edit cells and allow multiple lines of text
' Specify the cell block
fpSpread1.Col = 1
fpSpread1.Col2 = 2
fpSpread1.Row = -1
fpSpread1.Row2 = -1
fpSpread1.BlockMode = True
' Set the cells as edit cells
fpSpread1.CellType = CellTypeEdit
' Allow multiple lines of text
fpSpread1.TypeEditMultiLine = True
fpSpread1.BlockMode = False

' Set the starting number for the row headers
fpSpread1.StartingRowNumber = 1996
' Set the maximum number of rows
fpSpread1.MaxRows = 10

' Provide text for the first column
' Define the variable
Dim i As Integer
' Start the loop
For i = 1 To 10
    ' Specify the cells
    fpSpread1.Col = 1
    fpSpread1.Row = i
    ' Provide text
    fpSpread1.Text = "Beginning Inventory" + Chr$(10) + "Purchases" + Chr$(10) + "Sales"
Next i

' Set the width for specified columns
' Set the width for row headers
fpSpread1.ColWidth(0) = 5
' Set the width for column 1
fpSpread1.ColWidth(1) = 15
' Set the width for column 2
fpSpread1.ColWidth(2) = 7
' Set the width for column 3
fpSpread1.ColWidth(3) = 0.3
' Return the width of column 4
fWidth = fpSpread1.MaxTextColWidth(4)
' Set the width of column 4 to the returned value
fpSpread1.ColWidth(4) = fWidth

' Set the height for all rows
' Return the height of row 1
fWidth = fpSpread1.MaxTextRowHeight(1)
' Set the height of all columns to the returned value
fpSpread1.RowHeight(-1) = fWidth
' Set the height for the column header
fpSpread1.RowHeight(0) = 20

' Set the grid lines to display as dotted lines
fpSpread1.GridSolid = False

Copyright © GrapeCity, inc. All rights reserved.