如何将页眉放在Excel报表中.....从C#中导出Excel工作表 [英] How to put Header in Excel Report.....Im exporting Excel sheet from C#
本文介绍了如何将页眉放在Excel报表中.....从C#中导出Excel工作表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何将标题(日期,哪种类型的报告公司名称)放在Excel工作表报表的顶部..... Im从C#.Net导出Excel工作表...我的代码在下面
受保护的 void btnExcel_Click1(对象发件人,ImageClickEventArgs e)
{
Response.Clear();
Response.AddHeader(" ," 附件; filename = AttandanceReport.xls");
Response.Charset = " ;
Response.ContentType = " ;
System.IO.StringWriter stringWrite = 新 System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = 新 HtmlTextWriter(stringWrite);
// grdreport1.BorderStyle = BorderStyle.Solid;
// grdreport1.BorderWidth = 1;
// grdreport1.BackColor = Color.WhiteSmoke;
// grdreport1.GridLines = GridLines.Both;
grdreport1.Font.Name = " ;
grdreport1.Font.Size = FontUnit.XXSmall;
// grdreport1.HeaderStyle.BackColor = Color.DimGray;
// grdreport1.HeaderStyle.ForeColor = Color.White;
grdreport1.RowStyle.HorizontalAlign = HorizontalAlign.Center;
grdreport1.RowStyle.VerticalAlign = VerticalAlign.Top;
grdreport1.RenderControl(htmlWrite);
Response.Write(stringWrite.ToString());
Response.End();
}
解决方案
选中此
http://www. aspsnippets.com/Articles/Export-GridView-to-Excel-in-ASPNet-with-Formatting-using-C-and-VBNet.aspx [protected void btnExcel_Click1(object sender, ImageClickEventArgs e) { Response.Clear(); Response.AddHeader("Content-Disposition", "attachment;filename=AttandanceReport.xls"); Response.Charset = ""; Response.ContentType = "application/vnd.xls"; System.IO.StringWriter stringWrite = new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite); // grdreport1.BorderStyle = BorderStyle.Solid; // grdreport1.BorderWidth = 1; // grdreport1.BackColor = Color.WhiteSmoke; // grdreport1.GridLines = GridLines.Both; grdreport1.Font.Name = "Verdana"; grdreport1.Font.Size = FontUnit.XXSmall; // grdreport1.HeaderStyle.BackColor = Color.DimGray; // grdreport1.HeaderStyle.ForeColor = Color.White; grdreport1.RowStyle.HorizontalAlign = HorizontalAlign.Center; grdreport1.RowStyle.VerticalAlign = VerticalAlign.Top; grdreport1.RenderControl(htmlWrite); Response.Write(stringWrite.ToString()); Response.End(); }解决方案check this
http://www.aspsnippets.com/Articles/Export-GridView-to-Excel-in-ASPNet-with-Formatting-using-C-and-VBNet.aspx[^]
这篇关于如何将页眉放在Excel报表中.....从C#中导出Excel工作表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文