回复 5楼wangwuliSpread的帖子
可以通过 if 语句判断一下,如果为 null 或 “”,则把列头文本设置为一个空格:
- protected void Button1_Click(object sender, EventArgs e)
- {
- this.FpSpread1.OpenExcel(this.Server.MapPath("毕业论文报名表.xls"), FarPoint.Excel.ExcelOpenFlags.TruncateEmptyRowsAndColumns);
- this.FpSpread1.ActiveSheetView.AllowPage = false;
- this.FpSpread1.SaveChanges();
- int columnCount = this.FpSpread1.ActiveSheetView.ColumnCount;
- for (int i = 0; i < columnCount; i++)
- {
- if (string.IsNullOrEmpty(this.FpSpread1.ActiveSheetView.Cells[0, i].Text))
- this.FpSpread1.ActiveSheetView.ColumnHeader.Cells[0, 0].Text =" ";
- else
- this.FpSpread1.ActiveSheetView.ColumnHeader.Cells[0, i].Text = this.FpSpread1.ActiveSheetView.Cells[0, i].Text;
- }
- this.FpSpread1.ActiveSheetView.Rows.Remove(0, 1);
- }
复制代码 |