如何以pdf格式从datatable / dataset导出数据(不使用任何第三方dll。) [英] How to export data from datatable/dataset in pdf format (without using any 3rd party dll.)
本文介绍了如何以pdf格式从datatable / dataset导出数据(不使用任何第三方dll。)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在寻找有助于从网格/数据集/数据表导出数据而不使用任何第三方dll的解决方案(例如:iTextSharp)。
请帮助我找到解决方案。
提前致谢
我是什么尝试过:
Gridview至PDF [ ^ ]
I am looking for solution that will be helpful to export data from grid/data set/data table without using any third party dll (eg: iTextSharp).
please kindly Help me to find a solution.
Thanks in Advance
What I have tried:
Gridview to PDF[^]
推荐答案
你可以这样做
You can do this way
using (StringWriter sw = new StringWriter())
{
using (HtmlTextWriter hw = new HtmlTextWriter(sw))
{
//To Export all pages
GridView1.AllowPaging = false;
this.BindGrid();
GridView1.RenderControl(hw);
StringReader sr = new StringReader(sw.ToString());
Document pdfDoc = new Document(PageSize.A2, 10f, 10f, 10f, 0f);
HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
pdfDoc.Open();
htmlparser.Parse(sr);
pdfDoc.Close();
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=GridViewExport.pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Write(pdfDoc);
Response.End();
}
这篇关于如何以pdf格式从datatable / dataset导出数据(不使用任何第三方dll。)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文