找回密码
 立即注册

QQ登录

只需一步,快速开始

曹超

中级会员

3

主题

5

帖子

564

积分

中级会员

积分
564

活字格认证

最新发帖
曹超
中级会员   /  发表于:2015-5-12 10:48  /   查看:4399  /  回复:3
回复 13楼frank.zhang的帖子

这个导出excel和pdf的代码可不可以给段WinForm的代码

3 个回复

倒序浏览
frank.zhang
社区贡献组   /  发表于:2015-5-12 11:10:00
沙发
您好,
在WinForm下,只是改变了输出的方式。
  1. // Provide the page report you want to render.
  2. GrapeCity.ActiveReports.PageReport report = new GrapeCity.ActiveReports.PageReport(new
  3. System.IO.FileInfo(@"C:\Sample_PageReport.rdlx"));
  4. GrapeCity.ActiveReports.Document.PageDocument reportDocument = new
  5. GrapeCity.ActiveReports.Document.PageDocument(report);
  6. // Create a output directory
  7. System.IO.DirectoryInfo outputDirectory = new System.IO.DirectoryInfo(@"C:\MyPDF");
  8. outputDirectory.Create();
  9. // Provide settings for your rendering output.
  10. GrapeCity.ActiveReports.Export.Pdf.Page.Settings pdfSetting = new
  11. GrapeCity.ActiveReports.Export.Pdf.Page.Settings();
  12. GrapeCity.ActiveReports.Extensibility.Rendering.ISettings setting = pdfSetting;
  13. //Set the rendering extension and render the report.
  14. GrapeCity.ActiveReports.Export.Pdf.Page.PdfRenderingExtension pdfRenderingExtension =
  15. new GrapeCity.ActiveReports.Export.Pdf.Page.PdfRenderingExtension();
  16. GrapeCity.ActiveReports.Rendering.IO.FileStreamProvider outputProvider = new
  17. GrapeCity.ActiveReports.Rendering.IO.FileStreamProvider(outputDirectory,
  18. System.IO.Path.GetFileNameWithoutExtension(outputDirectory.Name));
  19. reportDocument.Render(pdfRenderingExtension, outputProvider, pdfSetting);
复制代码

  1. // Provide the page report you want to render.
  2. GrapeCity.ActiveReports.PageReport report = new
  3. GrapeCity.ActiveReports.PageReport(new
  4. System.IO.FileInfo(@"C:\Sample_PageReport.rdlx"));
  5. GrapeCity.ActiveReports.Document.PageDocument reportDocument = new
  6. GrapeCity.ActiveReports.Document.PageDocument(report);
  7. // Create an output directory
  8. System.IO.DirectoryInfo outputDirectory = new
  9. System.IO.DirectoryInfo(@"C:\MyExcel");
  10. outputDirectory.Create();
  11. // Provide settings for your rendering output.
  12. GrapeCity.ActiveReports.Export.Excel.Page.ExcelRenderingExtensionSettings
  13. excelSetting = new
  14. GrapeCity.ActiveReports.Export.Excel.Page.ExcelRenderingExtensionSettings();
  15. excelSetting.FileFormat = GrapeCity.ActiveReports.Export.Excel.Page.FileFormat.Xls;
  16. GrapeCity.ActiveReports.Extensibility.Rendering.ISettings setting = excelSetting;

  17. //Set the rendering extension and render the report.
  18. GrapeCity.ActiveReports.Export.Excel.Page.ExcelRenderingExtension
  19. excelRenderingExtension = new
  20. GrapeCity.ActiveReports.Export.Excel.Page.ExcelRenderingExtension();
  21. GrapeCity.ActiveReports.Rendering.IO.FileStreamProvider outputProvider = new
  22. GrapeCity.ActiveReports.Rendering.IO.FileStreamProvider(outputDirectory,
  23. System.IO.Path.GetFileNameWithoutExtension(outputDirectory.Name));
  24. reportDocument.Render(excelRenderingExtension, outputProvider,
  25. excelSetting.GetSettings());
复制代码


参考文档:http://arhelp.grapecity.com/webhelp/AR9/index.html#Rendering.html

评分

参与人数 1满意度 +5 收起 理由
曹超 + 5 非常感谢

查看全部评分

回复 使用道具 举报
曹超
中级会员   /  发表于:2015-5-12 13:14:00
板凳
非常感谢,初用AR9,多多学习
回复 使用道具 举报
frank.zhang
社区贡献组   /  发表于:2015-5-12 13:43:00
地板
感谢反馈。
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部