첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
유용한 소스 코드가 있으면 icodebroker@naver.com으로 보내주시면 감사합니다.
블로그 자료는 자유롭게 사용하세요.

■ 수표장(Checkbook Register) 만들기

----------------------------------------------------------------------------------------------------

 

// 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";

    }

}

----------------------------------------------------------------------------------------------------

Posted by 사용자 icodebroker
TAG

댓글을 달아 주세요