如果将列头设置成两行是否能够满足你的需求,设置两行列头,绑定数据源,并用代码设置一行显示成A/B/C...,比如使用下面的代码:
- DataTable dt = new DataTable();
- dt.Columns.Add("Col1");
- dt.Columns.Add("Col2");
- dt.Columns.Add("Col3");
- dt.Rows.Add(1, 2, 3);
- dt.Rows.Add(11, 2, 3);
- dt.Rows.Add(12, 2, 3);
- dt.Rows.Add(13, 2, 3);
- dt.Rows.Add(14, 2, 3);
- fpSpread1.Sheets[0].DataSource = dt;
- fpSpread1.Sheets[0].ColumnHeader.RowCount = 2;
- fpSpread1.Sheets[0].ColumnHeader.AutoTextIndex = 0;
- fpSpread1.Sheets[0].Columns[0].AllowAutoFilter = true;
- for (int i = 0; i < fpSpread1.Sheets[0].ColumnHeader.Columns.Count; i++)
- {
- fpSpread1.Sheets[0].ColumnHeader.Cells[1, i].Text = ((char)(65 + i)).ToString();
- }
复制代码 |