回复 6楼bamengqiu的帖子
按列绑定方法如下:
- DataTable dt = new DataTable("Test");
- DataRow dr = default(System.Data.DataRow);
- dt.Columns.Add("Name");
- dt.Columns.Add("Address");
- dt.Columns.Add("Email");
- dr = dt.NewRow();
- dr[0] = 2;
- dr[1] = 1;
- dr[2] = 5;
- dt.Rows.Add(dr);
- dr = dt.NewRow();
- dr[0] = 4;
- dr[1] = 2;
- dr[2] = 5;
- dt.Rows.Add(dr);
- dr = dt.NewRow();
- dr[0] = 3;
- dr[1] = 4;
- dr[2] = 5;
- dt.Rows.Add(dr);
- dr = dt.NewRow();
- dr[0] = 3;
- dr[1] = 4;
- dr[2] = 5;
- FpSpread1.Sheets[0].AutoGenerateColumns = false;
- FpSpread1.Sheets[0].DataSource = dt;
- FpSpread1.Sheets[0].Columns[0].DataField = "Name";
- FpSpread1.Sheets[0].Columns[1].DataField = "Email";
复制代码 |