文檔金喜正規買球>>FastReport中文文檔>>示例 3.打印月份名稱
示例 3.打印月份名稱
在上一個示例中,矩陣中打印了月份的數字。出現這種情況是因為 "Month "數據列包含月份的編號,而不是名稱。要打印月份名稱,請執行以下操作:
- 選擇打印月份編號的單元格。在本例中,該單元格的名稱為 "Cell8";
-
在 "BeforePrint "窗口中按下
按鈕并雙擊 "BeforePrint "事件;
- FastReport 將在報表腳本中添加一個空的事件處理程序。請編寫以下代碼:
private void Cell8_BeforePrint(object sender, EventArgs e) { string[] month Names = newstring[] { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" }; // Cell8 is a cell that prints the month number. // Cell8.Value is a value printed in the cell (i.e. the month number). // This value is of System.Object type, so we need to cast it to int Cell8.Text = monthNames[(int)Cell8.Value - 1]; }
運行報告后,結果如下:
