本文介绍了如何从客户端将gridview数据导出为pdf?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
i使用下面的代码将gridview数据导出为pdf,
受保护 void pdfLinkBtn_Click( object sender,EventArgs e)
{
const string attachment = attachment; filename = grdDetail.pdf;
Response.AddHeader( content-disposition,附件);
Response.ContentType = application / pdf;
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ClearContent();
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
studentReportGrid.RenderControl(htw);
StringReader sr = new StringReader(sw.ToString());
文件pdfDoc = new 文件(PageSize.A4,10f,10f,10f,0f);
HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
PdfWriter.GetInstance(pdfDoc,Response.OutputStream);
pdfDoc.Open();
htmlparser.Parse(sr);
pdfDoc.Close();
Response.Write(pdfDoc);
Response.End();
}
但是,在我的gridview中,两列数据从客户端绑定。所以这个数据不是' 't
从服务器端转换为pdf。如何将gridview中的整个数据导出到
pdf?可以使用脚本将gridview数据导出为pdf吗?
谢谢..
解决方案
Hi,
i export gridview data into pdf using the code below,
protected void pdfLinkBtn_Click(object sender, EventArgs e) { const string attachment = "attachment; filename= grdDetail.pdf"; Response.AddHeader("content-disposition", attachment); Response.ContentType = "application/pdf"; Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.ClearContent(); StringWriter sw = new StringWriter(); HtmlTextWriter htw = new HtmlTextWriter(sw); studentReportGrid.RenderControl(htw); StringReader sr = new StringReader(sw.ToString()); Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 10f, 0f); HTMLWorker htmlparser = new HTMLWorker(pdfDoc); PdfWriter.GetInstance(pdfDoc, Response.OutputStream); pdfDoc.Open(); htmlparser.Parse(sr); pdfDoc.Close(); Response.Write(pdfDoc); Response.End(); }
But, in my gridview two columns data bind from client side.so this data don''t
convert to pdf from server side.how to export whole data in gridview to
pdf?can export the gridview data to pdf using script?
Thanks..
解决方案
这篇关于如何从客户端将gridview数据导出为pdf?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!