■ 수표장(Checkbook Register)을 만드는 방법을 보여준다.
▶ 예제 코드 (C#)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
// Set up control and rows and columns in sheet. fpSpread1.Height = 330; fpSpread1.Width = 765; fpSpread1.Sheets[0].ColumnCount = 8; fpSpread1.Sheets[0].RowCount = 100; // Add text to column heading. fpSpread1.Sheets[0].ColumnHeader.Cells[0, 0].Text = "Check #"; fpSpread1.Sheets[0].ColumnHeader.Cells[0, 1].Text = "Date"; fpSpread1.Sheets[0].ColumnHeader.Cells[0, 2].Text = "Description"; fpSpread1.Sheets[0].ColumnHeader.Cells[0, 3].Text = "Tax?"; fpSpread1.Sheets[0].ColumnHeader.Cells[0, 4].Text = "Cleared?"; fpSpread1.Sheets[0].ColumnHeader.Cells[0, 5].Text = "Debit"; fpSpread1.Sheets[0].ColumnHeader.Cells[0, 6].Text = "Credit"; fpSpread1.Sheets[0].ColumnHeader.Cells[0, 7].Text = "Balance"; // Set column widths. fpSpread1.Sheets[0].Columns[0].Width = 70; fpSpread1.Sheets[0].Columns[1].Width = 50; fpSpread1.Sheets[0].Columns[2].Width = 175; fpSpread1.Sheets[0].Columns[3].Width = 40; fpSpread1.Sheets[0].Columns[4].Width = 65; fpSpread1.Sheets[0].Columns[5].Width = 100; fpSpread1.Sheets[0].Columns[6].Width = 100; fpSpread1.Sheets[0].Columns[7].Width = 125; // Create Check # column of number cells. FarPoint.Win.Spread.CellType.NumberCellType checkNumberCellType = new FarPoint.Win.Spread.CellType.NumberCellType(); checkNumberCellType.DecimalPlaces = 0; checkNumberCellType.MinimumValue = 1; checkNumberCellType.MaximumValue = 9999; checkNumberCellType.ShowSeparator = false; fpSpread1.Sheets[0].Columns[0].CellType = checkNumberCellType; // Create Date column of date-time cells. FarPoint.Win.Spread.CellType.DateTimeCellType dateDateTimeCellType = new FarPoint.Win.Spread.CellType.DateTimeCellType(); dateDateTimeCellType.DateTimeFormat = FarPoint.Win.Spread.CellType.DateTimeFormat.ShortDate; fpSpread1.Sheets[0].Columns[1].CellType = dateDateTimeCellType; // Create Description column of text cells. FarPoint.Win.Spread.CellType.TextCellType descriptionTextCellType = new FarPoint.Win.Spread.CellType.TextCellType(); descriptionTextCellType.MaxLength = 100; fpSpread1.Sheets[0].Columns[2].CellType = descriptionTextCellType; /// Create Tax? and Cleared? columns of check box cells. FarPoint.Win.Spread.CellType.CheckBoxCellType checkBoxCellType = new FarPoint.Win.Spread.CellType.CheckBoxCellType(); checkBoxCellType.ThreeState = false; fpSpread1.Sheets[0].Columns[3].CellType = checkBoxCellType; fpSpread1.Sheets[0].Columns[4].CellType = checkBoxCellType; // Create the Debit, Credit, and Balance columns of currency cells. FarPoint.Win.Spread.CellType.CurrencyCellType currencyCellType = new FarPoint.Win.Spread.CellType.CurrencyCellType(); currencyCellType.LeadingZero = FarPoint.Win.Spread.CellType.LeadingZero.Yes; currencyCellType.NegativeRed = true; currencyCellType.FixedPoint = true; fpSpread1.Sheets[0].Columns[5].CellType = currencyCellType; fpSpread1.Sheets[0].Columns[6].CellType = currencyCellType; fpSpread1.Sheets[0].Columns[7].CellType = currencyCellType; // Set formula for calculating balance. fpSpread1.Sheets[0].ReferenceStyle = FarPoint.Win.Spread.Model.ReferenceStyle.R1C1; for(int i = 0; i <= fpSpread1.ActiveSheet.RowCount - 1; i++) { if(i == 0) { fpSpread1.Sheets[0].Cells[i, 7].Formula = "RC[-1] - RC[-2]"; } else { fpSpread1.Sheets[0].Cells[i, 7].Formula = "RC[-1] - RC[-2] + R[-1]C"; } } |