本文介绍了在将gridview数据导出到excell工作表的同时,如何在excell工作表的顶部提供标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我已将gridview数据导入到PDF中,但问题是我无法通过代码创建工作表的标题
下面是代码:
Hi All,
I have imported gridview data to a PDF but the problem is that I am unable to create a heading for the sheet through code
Below is the code:
string attachment = "attachment; filename=Export.xls";
Response.ClearContent();
Response.AddHeader("content-disposition", attachment);
Response.ContentType = "application/vnd.ms-excel";
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
// Create a form to contain the grid
HtmlForm frm = new HtmlForm();
GridView1.Parent.Controls.Add(frm);
frm.Attributes["runat"] = "server";
frm.Controls.Add(GridView1);
frm.RenderControl(htw);
//GridView1.RenderControl(htw);
Response.Write(sw.ToString());
Response.End();
我的代码正在100%输出Excel工作表.请告诉我如何添加标题.
提前致谢.
My code is working 100% to output the excel sheet. Please tell me how to add a heading.
Thanks in Advance.
推荐答案
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Report</title>
</head>
<body>
<h1>Report of best songs of all time</h1>
<!-- This should point to your script above. -->
<iframe src="excel_report.aspx" width="100%" height="300px">
<p>Your browser does not support iframes.</p>
</iframe>
</body>
这篇关于在将gridview数据导出到excell工作表的同时,如何在excell工作表的顶部提供标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!