Example
The following example creates a sheet that accepts item prices, produces a total purchase, and calculates the change to return from a given amount of cash received.
C++
void CmyWnd::MyFunc()
{
int x;
// Set up labels
m_Spread.SetColWidth(1,15);
m_Spread.SetCol(1);
m_Spread.SetRow(-1);
m_Spread.SetCellType(5);
for (x = 1; x<=5; x++) {
m_Spread.SetRow(x);
m_Spread.SetText("Item price");
}
m_Spread.SetRow(6);
m_Spread.SetText("Total");
m_Spread.SetRow(7);
m_Spread.SetText("Cash received");
m_Spread.SetRow(8);
m_Spread.SetText("Change due");
// Set up currency cells for second column
m_Spread.SetBlockMode(TRUE);
m_Spread.SetCol(2);
m_Spread.SetRow(1);
m_Spread.SetCol2(2);
m_Spread.SetRow2(8);
m_Spread.SetCellType(12);
m_Spread.SetTypeCurrencyLeadingZero(2);
m_Spread.SetTypeCurrencyShowSymbol(TRUE);
m_Spread.SetValue("0");
m_Spread.SetBlockMode(FALSE);
// Set up item price to be between 0 and 10
m_Spread.SetBlockMode(TRUE);
m_Spread.SetCol(2);
m_Spread.SetRow(1);
m_Spread.SetCol2(2);
m_Spread.SetRow2(5);
m_Spread.SetTypeCurrencyMax(10);
m_Spread.SetTypeCurrencyMin(0);
m_Spread.SetBlockMode(FALSE);
// Calculate the change
m_Spread.SetCol(2);
m_Spread.SetRow(8);
m_Spread.SetFormula("B7 - B6");
// Calculate total purchase
m_Spread.SetCol(2);
m_Spread.SetRow(6);
m_Spread.SetFormula("sum(B1:B5)");
}
Visual Basic
Private Sub Form_Load()
Dim x As Integer
' Set up labels
fpSpread1.ColWidth(1) = 15
fpSpread1.Col = 1
fpSpread1.Row = -1
fpSpread1.CellType = CellTypeStaticText
For x = 1 To 5
fpSpread1.Row = x
fpSpread1.Text = "Item price"
Next x
fpSpread1.Row = 6
fpSpread1.Text = "Total"
fpSpread1.Row = 7
fpSpread1.Text = "Cash received"
fpSpread1.Row = 8
fpSpread1.Text = "Change due"
' Set up currency cells for second column
fpSpread1.BlockMode = True
fpSpread1.Col = 2
fpSpread1.Row = 1
fpSpread1.Col2 = 2
fpSpread1.Row2 = 8
fpSpread1.CellType = CellTypeCurrency
fpSpread1.TypeCurrencyLeadingZero = TypeLeadingZeroYes
fpSpread1.TypeCurrencyShowSymbol = True
fpSpread1.Value = "0"
fpSpread1.BlockMode = False
' Set up item price to be between 0 and 10
fpSpread1.BlockMode = True
fpSpread1.Col = 2
fpSpread1.Row = 1
fpSpread1.Col2 = 2
fpSpread1.Row2 = 5
fpSpread1.TypeCurrencyMax = 10
fpSpread1.TypeCurrencyMin = 0
fpSpread1.BlockMode = False
' Set up formulas
fpSpread1.Col = 2
fpSpread1.Row = 8
fpSpread1.Formula = "B7 - B6"
fpSpread1.Col = 2
fpSpread1.Row = 6
fpSpread1.Formula = "sum(B1:B5)"
End Sub