文档彩票走势图>>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]; }
运行报告后,结果如下: