找回密码
 立即注册

QQ登录

只需一步,快速开始

xeilin

注册会员

6

主题

14

帖子

108

积分

注册会员

积分
108
最新发帖
xeilin
注册会员   /  发表于:2016-3-7 16:57  /   查看:3000  /  回复:2
本帖最后由 Lenka.Guo 于 2016-3-7 17:18 编辑

我查询的数据有几千条用实例代码导出Excel后是按照Sheet1,Sheet2,。。。。。这样导出的,请问能不能一次把几千条数据 导到一个Sheet1里面啊。
代码:
            string report = "A13销售报表测试";

            // Provide the page report you want to render.
            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 = "SQL";
            //DataSource1
            _reportDef.Report.DataSources[0].ConnectionProperties.ConnectString = @"user id=sa;data source=(local);initial catalog=报表测试数据库;password=123456;";
            //_reportDef.Report.DataSources[0].ConnectionProperties.ConnectString = "DataSource1";
            //_reportDef.Report.DataSources[0].Name = "DataSet1";
            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;
            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=客户订单.xls");
            outputProvider.GetPrimaryStream().OpenStream().CopyTo(ms);
            Response.BinaryWrite(ms.ToArray());
            Response.End();

2 个回复

倒序浏览
xeilin
注册会员   /  发表于:2016-3-7 16:59:42
沙发
备注:是报表浏览器有好多分页导出都是按照分页导出的累加的一个分页一个Sheet,我想导出直接都是一个Sheet1,里面都是所有数据,谢谢指点。
回复 使用道具 举报
Lenka.Guo讲师达人认证 悬赏达人认证
超级版主   /  发表于:2016-3-7 17:18:02
板凳
将MultiSheet 属性设置为false: excelSetting.MultiSheet = false;
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部