导出的excel在Header下面无缘无故多出来一行
关键方法
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Cells[0].Attributes.Add( "style ", "vnd.ms-excel.numberformat:@; ");
}
switch (e.Row.RowType)
{
case DataControlRowType.Header:
//第一行的表头
TableCellCollection tcHeader = e.Row.Cells;//retrun TablecellCollection get a collection of TableCell object that represents the cells of a row (in a Table Control)
tcHeader.Clear();
tcHeader.Add(new TableHeaderCell());
tcHeader[0].Attributes.Add( "colspan ", "4 "); //跨Column
tcHeader[0].Text = "CheckList for AMS Information -LCL ";
tcHeader.Add(new TableHeaderCell());
tcHeader[1].Attributes.Add( "colspan ", "1 ");
tcHeader[1].Text = "Date: " + DateTime.Now.ToString( "MMM.dd ", new System.Globalization.CultureInfo( "en-GB ")) + " </th> </tr> <tr> ";// + " </th> </tr> <tr> ";加?
break;
case DataControlRowType.DataRow:
TableCell tc = new TableCell();