【页面效果】
【后台代码】
Page_Load方法里面的代码如下
protected void btnQuery_Click(object sender, EventArgs e)
{
//var dt = GetDataTable();
var dt = Model.ProjectBudget.GetData();
//关闭自动生成列属性
this.FpSpread1.Sheets[0].AutoGenerateColumns = false;
//绑定数据源
this.FpSpread1.DataSource = dt;
this.FpSpread1.Sheets[0].Columns[0].DataField = "A";
this.FpSpread1.Sheets[0].Columns[1].DataField = "项目";
this.FpSpread1.Sheets[0].Columns[2].DataField = "所属部门";
this.FpSpread1.Sheets[0].Columns[3].DataField = "预算事项编码";
this.FpSpread1.Sheets[0].Columns[4].DataField = "预算事项名称";
this.FpSpread1.Sheets[0].Columns[5].DataField = "预算科目代码";
this.FpSpread1.Sheets[0].Columns[6].DataField = "预算科目名称";
this.FpSpread1.Sheets[0].Columns[7].DataField = "年度";
this.FpSpread1.Sheets[0].Columns[8].DataField = "1月";
this.FpSpread1.Sheets[0].Columns[9].DataField = "2月";
this.FpSpread1.Sheets[0].Columns[10].DataField = "3月";
this.FpSpread1.Sheets[0].Columns[11].DataField = "4月";
this.FpSpread1.Sheets[0].Columns[12].DataField = "5月";
this.FpSpread1.Sheets[0].Columns[13].DataField = "6月";
this.FpSpread1.Sheets[0].Columns[14].DataField = "7月";
this.FpSpread1.Sheets[0].Columns[15].DataField = "8月";
this.FpSpread1.Sheets[0].Columns[16].DataField = "9月";
this.FpSpread1.Sheets[0].Columns[17].DataField = "10月";
this.FpSpread1.Sheets[0].Columns[18].DataField = "11月";
this.FpSpread1.Sheets[0].Columns[19].DataField = "12月";
foreach (SheetView sheet in this.FpSpread1.Sheets)
{
sheet.AllowPage = false;
}
this.FpSpread1.Sheets[0].RowCount = 100;
this.FpSpread1.Sheets[0].ColumnCount = 100;
} |
|