我使用Telerik報表設計器(獨立版)設計報表(.trdx),如何以編程方式將它導出到C#代碼中的pdf文件?如何將使用Telerik Reporting(.trdx)創建的報告導出爲pdf?
1
A
回答
1
我使用下面的代碼片段。它將.trdx文件反序列化,然後創建一個Report(Telerik.Reporting.Report)實例。此報告實例可以轉換爲pdf。
System.Xml.XmlReaderSettings settings = new System.Xml.XmlReaderSettings();
settings.IgnoreWhitespace = true;
//read the .trdx file contents
using (System.Xml.XmlReader xmlReader = System.Xml.XmlReader.Create(path_to your_trdx_file, settings))
{
Telerik.Reporting.XmlSerialization.ReportXmlSerializer xmlSerializer =
new Telerik.Reporting.XmlSerialization.ReportXmlSerializer();
//deserialize the .trdx report XML contents
Telerik.Reporting.Report report = (Telerik.Reporting.Report)
xmlSerializer.Deserialize(xmlReader);
string mimType = string.Empty;
string extension = string.Empty;
Encoding encoding = null;
// call Render() and retrieve raw array of bytes
// write the pdf file
byte[] buffer = Telerik.Reporting.Processing.ReportProcessor.Render(
"PDF", report, null, out mimType, out extension, out encoding);
// create a new file on disk and write the byte array to the file
FileStream fs = new FileStream(Path_you_need_to_save_the_pdf_file, FileMode.Create);
fs.Write(buffer, 0, buffer.Length);
fs.Flush();
fs.Close();
}
0
如果用戶Telerik報告2012或更新需要改變此
enter code here
XmlReaderSettings設置新= XmlReaderSettings()上面的代碼; settings.IgnoreWhitespace = true;
//read the .trdx file contents
using (
XmlReader xmlReader =
XmlReader.Create(you trdx file path,
settings))
{
ReportXmlSerializer xmlSerializer =
new ReportXmlSerializer();
//deserialize the .trdx report XML contents
Report report = (Report)xmlSerializer.Deserialize(xmlReader);
Telerik.Reporting.InstanceReportSource instanceReportSource = new Telerik.Reporting.InstanceReportSource
{
ReportDocument = report
};
string mimType = string.Empty;
string extension = string.Empty;
//Encoding encoding = null;
// call Render() and retrieve raw array of bytes
// write the pdf file
ReportProcessor reportProcessor = new ReportProcessor();
RenderingResult renderingResult = reportProcessor.RenderReport("DOCX", instanceReportSource, null);
// create a new file on disk and write the byte array to the file
FileStream fs = new FileStream(@"D:\test\Dashboard.DOCX", FileMode.Create);
fs.Write(renderingResult.DocumentBytes, 0, renderingResult.DocumentBytes.Length);
fs.Flush();
fs.Close();
}
相關問題
- 1. 如何將JIRA報告導出爲PDF?
- 2. Telerik報告沒有trdx文件
- 3. 頁腳沒有出現在Reporting Services 2005導出爲PDF報告
- 4. Telerik報告中的本地化(TRDX報告)
- 5. 轉換在Visual Studio中使用的trdx文件(Telerik Reporting)
- 6. SQL ServerReporting Services - 將報告導出爲PDF
- 7. 如何顯式導出telerik報告?
- 8. 使用Reporting Services將SSRS報告另存爲pdf
- 9. 如何將Telerik報表模板(.trdx)轉換爲DevExpress報表模板(.repx)
- 10. 如何使用Asp.Net中的telerik報告創建動態報告MVC
- 11. 如何將本地報告導出爲pdf和excel文件?
- 12. 如何將結果導出爲PDF報告?
- 13. 如何爲SQL Server 2005 Reporting Services報告創建模板?
- 14. 將水晶報告導出到pdf
- 15. 將Reporting Server 2008中的報告轉換爲PDF文檔
- 16. 報告查看器不顯示使用Sql Server Reporting Services創建的報告
- 17. 使用報告服務將報告導出爲csv格式?
- 18. 在Silverlight 4中創建報告(PDF/Word導出)主要選項是什麼?
- 19. 如何使用oracle將水晶報表導出爲pdf
- 20. 從PDF導入Sql Server Reporting Services 2005報告
- 21. Reporting Services報告
- 22. 如何使用Telerik Reporting以編程方式創建交叉表?
- 23. 如何將HTML導出爲PDF將Telerik與ASP.NET MVC結合使用
- 24. 我想使用telerik控件將radchart導出爲pdf格式
- 25. 將超過1200頁的報告導出爲PDF
- 26. 通過Servlet或JSP將JasperReport的報告導出爲pdf
- 27. 如何使用PL/SQL創建PDF報告
- 28. 執行Access 2007報告並以編程方式將該報告導出爲PDF?
- 29. 將Reporting Services報告導出到Excel時抑制分頁符
- 30. 以PDF格式導出訪問報告