博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
葡萄城报表-导出输出
阅读量:5888 次
发布时间:2019-06-19

本文共 3504 字,大约阅读时间需要 11 分钟。

1.使用XlsExport导出

以导出excel格式为例,XlsExport能够支持所有的报表类型

GrapeCity.ActiveReports.PageReport _reportDef = new GrapeCity.ActiveReports.PageReport(new System.IO.FileInfo(Server.MapPath("/Reports/" + report + ".rdlx")));            _reportDef.Report.DataSources[0].DataSourceReference = "";            _reportDef.Report.DataSources[0].ConnectionProperties.DataProvider = "OLEDB";            _reportDef.Report.DataSources[0].ConnectionProperties.ConnectString = string.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};", Server.MapPath("/Data/NWind_CHS.mdb"));            GrapeCity.ActiveReports.Document.PageDocument _reportRuntime = new GrapeCity.ActiveReports.Document.PageDocument(_reportDef);                        GrapeCity.ActiveReports.Export.Excel.Section.XlsExport XlsExport1 = new GrapeCity.ActiveReports.Export.Excel.Section.XlsExport();            System.IO.MemoryStream ms = new System.IO.MemoryStream();            XlsExport1.FileFormat = GrapeCity.ActiveReports.Export.Excel.Section.FileFormat.Xlsx;            XlsExport1.Export(_reportRuntime, ms);            Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";            Response.AddHeader("content-disposition", Server.UrlPathEncode("attachment;filename=MyExport.xlsx"));            Response.BinaryWrite(ms.ToArray());            Response.End();

2.使用Render的方式导出

Render只能用来导出页面报表和RDL报表,但是对性能和样式都有很大的提升

GrapeCity.ActiveReports.PageReport _reportDef = new GrapeCity.ActiveReports.PageReport(new System.IO.FileInfo(Server.MapPath("/Reports/" + report + ".rdlx")));            _reportDef.Report.DataSources[0].DataSourceReference = "";            _reportDef.Report.DataSources[0].ConnectionProperties.DataProvider = "OLEDB";            _reportDef.Report.DataSources[0].ConnectionProperties.ConnectString = string.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};", Server.MapPath("/Data/NWind_CHS.mdb"));            GrapeCity.ActiveReports.Document.PageDocument _reportRuntime = new GrapeCity.ActiveReports.Document.PageDocument(_reportDef);            // Create an output directory            System.IO.MemoryStream ms = new System.IO.MemoryStream();            // Provide settings for your rendering output.            GrapeCity.ActiveReports.Export.Excel.Page.ExcelRenderingExtensionSettings            excelSetting = new GrapeCity.ActiveReports.Export.Excel.Page.ExcelRenderingExtensionSettings();            excelSetting.FileFormat = GrapeCity.ActiveReports.Export.Excel.Page.FileFormat.Xls;            //excelSetting.MultiSheet = false;            GrapeCity.ActiveReports.Extensibility.Rendering.ISettings setting = excelSetting;            //Set the rendering extension and render the report.            GrapeCity.ActiveReports.Export.Excel.Page.ExcelRenderingExtension            excelRenderingExtension = new            GrapeCity.ActiveReports.Export.Excel.Page.ExcelRenderingExtension();            GrapeCity.ActiveReports.Rendering.IO.MemoryStreamProvider outputProvider = new GrapeCity.ActiveReports.Rendering.IO.MemoryStreamProvider();            _reportRuntime.Render(excelRenderingExtension, outputProvider, excelSetting.GetSettings());            Response.ContentType = "application/vnd.ms-excel";            Response.AddHeader("content-disposition", "inline;filename=MyExport.xls");            outputProvider.GetPrimaryStream().OpenStream().CopyTo(ms);            Response.BinaryWrite(ms.ToArray());            Response.End();

转载于:https://www.cnblogs.com/xzpblog/p/5117899.html

你可能感兴趣的文章
python之 前端HTML/CSS基础知识学习笔记
查看>>
Sencha Touch NestList 如何载入tree结构的数据
查看>>
工具栏图标切换
查看>>
Openlayers系列(一)关于地图投影相关错误的解决方案
查看>>
php多进程中的阻塞与非阻塞
查看>>
TensorFlow学习笔记(五)图像数据处理
查看>>
crossplatform---Nodejs in Visual Studio Code 05.Swig+Bootstrap
查看>>
论JVM爆炸的几种姿势及自救方法---转载
查看>>
keystone 手动建立租户,用户,角色,服务,端口
查看>>
排序之快速排序
查看>>
Win32编程day07 学习笔记
查看>>
PYTHON2.day09
查看>>
PYTHON2.day05
查看>>
ocp题库更新,052最新考试题及答案整理-31
查看>>
Git-常用命令集合
查看>>
最近学习到的一些
查看>>
Windows环境下免安装版MySQL 5.6.11安装配置详解
查看>>
leetcode记录-反转整数
查看>>
matlab-画个拱桥和倒影?
查看>>
8.5 exit函数-进程控制
查看>>