本文介绍了Expoert Grid为pdf格式,但数据无法以pdf格式显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我想以pdf格式导出网格数据这是我的以下代码,问题发生 作为pdf打开但数据不显示。请帮我 ???解决问题 Response.ContentType =application / pdf; Response.AddHeader(content-disposition,附件; filename = UserDetails.pdf); Response.Cache.SetCacheability(HttpCacheability.NoCache); StringWriter sw = new StringWriter(); HtmlTextWriter hw = new HtmlTextWriter(sw); GrdATDataView.AllowPaging = false; GrdATDataView.DataBind(); GrdATDataView.RenderControl( hw); GrdATDataView.HeaderRow.Style.Add(width,15%); GrdATDataView.HeaderRow.Style.Add(font-size ,10px); GrdATDataView.Style.Add(text-decoration,none); GrdATDataView.Style.Add(font-family ,Arial,Helvetica,sans-serif;); GrdATDataView.Style.Add(font-size,8px); StringReader sr = new StringReader(sw.ToString()); Docum ent pdfDoc = new Document(PageSize.A2,7f,7f,7f,0f); HTMLWorker htmlparser = new HTMLWorker(pdfDoc); PdfWriter.GetInstance(pdfDoc, Response.OutputStream); pdfDoc.Open(); htmlparser.Parse(sr); Response.Write(pdfDoc); pdfDoc.Close(); Response.End(); 解决方案 检查这里...我查了一下,工作正常: - http://www.aspdotnet-suresh.com/2011/04/how-to-export-gridview-data-to-pdf.html [ ^ ] hi,I want to export grid data in pdf format this is my following code,problem occuras pdf open but data not display. please help me ??? to solving problem Response.ContentType = "application/pdf"; Response.AddHeader("content-disposition", "attachment;filename=UserDetails.pdf"); Response.Cache.SetCacheability(HttpCacheability.NoCache); StringWriter sw = new StringWriter(); HtmlTextWriter hw = new HtmlTextWriter(sw); GrdATDataView.AllowPaging = false; GrdATDataView.DataBind(); GrdATDataView.RenderControl(hw); GrdATDataView.HeaderRow.Style.Add("width", "15%"); GrdATDataView.HeaderRow.Style.Add("font-size", "10px"); GrdATDataView.Style.Add("text-decoration", "none"); GrdATDataView.Style.Add("font-family", "Arial, Helvetica, sans-serif;"); GrdATDataView.Style.Add("font-size", "8px"); StringReader sr = new StringReader(sw.ToString()); Document pdfDoc = new Document(PageSize.A2, 7f, 7f, 7f, 0f); HTMLWorker htmlparser = new HTMLWorker(pdfDoc); PdfWriter.GetInstance(pdfDoc, Response.OutputStream); pdfDoc.Open(); htmlparser.Parse(sr); Response.Write(pdfDoc); pdfDoc.Close(); Response.End(); 解决方案 check here...i checked, it's working fine :- http://www.aspdotnet-suresh.com/2011/04/how-to-export-gridview-data-to-pdf.html[^] 这篇关于Expoert Grid为pdf格式,但数据无法以pdf格式显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-15 19:16