我需要将dx-data-grid
(devExpress网格)导出为pdf文档。有一种可用于将数据导出到excel的解决方案,但是如何将其导出为pdf?如何将dx-data-grid devexpress导出为pdf?
回答
这是不允许的dxDataGrid的那一刻,从DX支持回答:
目前,dxDataGrid不提供出口到PDF功能。我们知道这个限制,这个功能在我们的TO-DO列表中。但是,我不能为您提供关于何时可能引入的准确日期。 https://www.devexpress.com/Support/Center/Question/Details/T458071/dxdatagrid-is-it-possible-to-export-data-to-pdf
但是你可以在你的应用程序的服务器端生成你自己的pdf文件。使用iTextSharp的,本文介绍了如何做到这一点http://www.c-sharpcorner.com/UploadFile/f4f047/generating-pdf-file-using-C-Sharp/
using iTextSharp.text;
using iTextSharp.text.pdf;
protected void GeneratePDF(object sender, System.EventArgs e)
{
using(System.IO.MemoryStream memoryStream = new System.IO.MemoryStream())
{
Document document = new Document(PageSize.A4, 10, 10, 10, 10);
PdfWriter writer = PdfWriter.GetInstance(document, memoryStream);
document.Open();
Chunk chunk = new Chunk("This is from chunk. ");
document.Add(chunk);
Phrase phrase = new Phrase("This is from Phrase.");
document.Add(phrase);
Paragraph para = new Paragraph("This is from paragraph.");
document.Add(para);
string text = @ "you are successfully created PDF file.";
Paragraph paragraph = new Paragraph();
paragraph.SpacingBefore = 10;
paragraph.SpacingAfter = 10;
paragraph.Alignment = Element.ALIGN_LEFT;
paragraph.Font = FontFactory.GetFont(FontFactory.HELVETICA, 12f, BaseColor.GREEN);
paragraph.Add(text);
document.Add(paragraph);
document.Close();
byte[] bytes = memoryStream.ToArray();
memoryStream.Close();
Response.Clear();
Response.ContentType = "application/pdf";
string pdfName = "User";
Response.AddHeader("Content-Disposition", "attachment; filename=" + pdfName + ".pdf");
Response.ContentType = "application/pdf";
Response.Buffer = true;
Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache);
Response.BinaryWrite(bytes);
Response.End();
Response.Close();
}
}
谢谢你解决方案的工作,但我发现解决方案没有再次调用服务器,可能的解决方案是将数据网格的数据源转换为HTML表格。这个例子也可以应用于datagrid,并使用JS库从HTML转换为PDF。这个链接帮助我做到这一点:https://www.devexpress.com/Support/Center/Question/Details/T113743/dxdatagrid-provide-the-capability-to-export-data – Bassem
很高兴知道您找到了一个选项,希望他们能够在下一个版本中实现导出为pdf的格式 –
很遗憾,他们不会实现它,他们不会将其放入根地图中用于下一个版本 – Bassem
- 1. 如何将数据从devexpress gridview导出为pdf在mvc
- 2. 如何将JIRA报告导出为PDF?
- 3. 如何将UIView导出为PDF文件
- 4. 如何将Drupal图书导出为PDF?
- 5. 将JasperReport导出为PDF OutputStream?
- 6. 将图像导出为PDF
- 7. Devexpress ASPxGridViewExporter将不会导出前导零
- 8. 将Julia输出导出为PDF
- 9. Vaadin导出为pdf
- 10. KendoUI导出为PDF
- 11. 将DevExpress XtraReport导出到文本页面
- 12. 将Crystal Report导出为PDF冻结 - Vb.Net2003
- 13. 将SVG图表导出为PDF
- 14. 将MS图表导出为PDF和Excel
- 15. 将Redmine问题标签导出为PDF
- 16. 使用applescript将文件导出为pdf
- 17. 将html导出为PDF的工具
- 18. 将php数据导出为pdf版本
- 19. SQL ServerReporting Services - 将报告导出为PDF
- 20. 将Sqlite数据导出为PDF或Excel
- 21. 将GridView导出为PDF格式的c#
- 22. 将pandas表格导出为pdf
- 23. 在PHP中将html导出为PDF?
- 24. 将SVG元素导出为PDF?
- 25. 将.NET WinForms表单导出为PDF?
- 26. 将当前网页导出为pdf
- 27. 使用Adobe X将PDF导出为HTML
- 28. 将Flash内容导出为PDF?
- 29. 将canvas图表导出为PDF
- 30. 使用Python将MySQL表导出为PDF
请清楚你想要达到的目标。 –
需要点击按钮,然后所有网格数据导出为PDF格式相同的网格结构 – Bassem
支持说:[此刻,PDF文件格式不可用于网格小部件。只支持Excel格式。](https://www.devexpress.com/Support/Center/Question/Details/T500288/how-to-export-dx-data-grid-to-pdf)。 – ventiseis