你好,有两种方式可以设置以上操作
1.通过代码生成:代码如下
- //设置表单行列数
- this.fpSpread1.Sheets[0].RowCount = 40;
- this.fpSpread1.Sheets[0].ColumnCount = 9;
- //设置列头单元格合并项
- this.fpSpread1.Sheets[0].ColumnHeader.RowCount = 2;
- this.fpSpread1.Sheets[0].ColumnHeader.Cells[0, 0].ColumnSpan = 2;
- this.fpSpread1.Sheets[0].ColumnHeader.Cells[1, 0].ColumnSpan = 2;
- this.fpSpread1.Sheets[0].ColumnHeader.Cells[0, 2].ColumnSpan = 2;
- this.fpSpread1.Sheets[0].ColumnHeader.Cells[0, 4].RowSpan = 2;
- this.fpSpread1.Sheets[0].ColumnHeader.Cells[0, 5].ColumnSpan = 4;
- //设置列头单元格文本
- this.fpSpread1.Sheets[0].ColumnHeader.Cells[0, 0].Text = "Coustomer Details";
- this.fpSpread1.Sheets[0].ColumnHeader.Cells[1, 0].Text = "Coustomer";
- this.fpSpread1.Sheets[0].ColumnHeader.Cells[0, 2].Text = "Invoice";
- this.fpSpread1.Sheets[0].ColumnHeader.Cells[0, 4].Text = "ToTalDue";
- this.fpSpread1.Sheets[0].ColumnHeader.Cells[0, 5].Text = "AgedReceivables";
- this.fpSpread1.Sheets[0].ColumnHeader.Cells[1, 1].Text = "Order#";
- this.fpSpread1.Sheets[0].ColumnHeader.Cells[1, 2].Text = "date";
- this.fpSpread1.Sheets[0].ColumnHeader.Cells[1, 3].Text = "Coustomer";
- this.fpSpread1.Sheets[0].ColumnHeader.Cells[1, 5].Text = "0-30 Days";
- this.fpSpread1.Sheets[0].ColumnHeader.Cells[1, 6].Text = "31-60 Days";
- this.fpSpread1.Sheets[0].ColumnHeader.Cells[1, 7].Text = "61-90 Days";
- this.fpSpread1.Sheets[0].ColumnHeader.Cells[1, 8].Text = "90+ Days";
- //设置列头第一行字体
- this.fpSpread1.Sheets[0].ColumnHeader.Rows[0].Font = new Font("Calibri",10, FontStyle.Bold);
- //保存到 XML 文件
- this.fpSpread1.Save(@"E:\test.xml", false);
复制代码 2.通过 Spread 设计器:如图
注:其中仅演示列头中的列合并,行合并操作与其类似,都可在表头编辑器中实现。 |