找回密码
 立即注册

QQ登录

只需一步,快速开始

yf182187239

中级会员

2

主题

10

帖子

870

积分

中级会员

积分
870

活字格认证

最新发帖
yf182187239
中级会员   /  发表于:2014-5-23 15:27  /   查看:10485  /  回复:13
这是.rdlx的
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(&quotrovider=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);

请问如果实现.cs的区域报表在.aspx页面的导出

13 个回复

倒序浏览
roger.wang
社区贡献组   /  发表于:2014-5-23 15:36:00
沙发
区域报表的导出类似页面报表(*.rdlx),有2种导出方法:
方法一: 前端JavaScript导出 http://blog.gcpowertools.com.cn/ ... _Client_Export.aspx
方法二:后端cs代码导出
http://blog.gcpowertools.com.cn/post/2012/11/28/为区域报表导出为PDF添加进度显示功能.aspx

报表的导出帮助文档,路径为:ActiveReports 8 > ActiveReports User Guide > How To > Section Report How To > Export a Section Report
回复 使用道具 举报
yf182187239
中级会员   /  发表于:2014-5-23 16:16:00
板凳
回复太快了,非常感谢
回复 使用道具 举报
roger.wang
社区贡献组   /  发表于:2014-5-23 16:29:00
地板
回复 3楼yf182187239的帖子

客气了。
回复 使用道具 举报
yf182187239
中级会员   /  发表于:2014-5-26 11:00:00
5#
您好,还有2个问题:
1、viewMode = GetViewModel('WebViewer1');  
     点击导出的时候,一直报‘viewMode’为空或不是对象,GetViewModel这个方法在项目里找不到,是自带的还是?
2、 ExportType = { Pdf, Html, Word, Xls, Xml }
     ExportType 包含.txt、.csv吗?
3、report1.Document.LocateDataSource += new GrapeCity.ActiveReports.LocateDataSourceEventHandler(Document_LocateDataSource);
      这段给.rdlx报表赋值的代码,在Page_Load的IsPostBack外执行,或者在!IsPostBack内执行都是可以的,为什么在按钮事件中执行无法执行Document_LocateDataSource方法,也没有报任何错误,只是在后面导出报表时报错。
回复 使用道具 举报
roger.wang
社区贡献组   /  发表于:2014-5-26 11:54:00
6#
1 GetViewModel 这个是AR前端的方法,自带的,如2#的demo中用到了。  请上传一下您用到的代码,另外,您用的浏览器版本告之。
2 ExportType支持类型:Html、Image  、None 、Pdf、Word  、Xls、Xml
   参考自帮助文档:GrapeCity.ActiveReports.Viewer.Win.v8 Assembly > GrapeCity.Viewer.Common.Model Namespace : ExportType Enumeration
3 同问题1,我需要分析一下您的代码。
回复 使用道具 举报
yf182187239
中级会员   /  发表于:2014-5-26 13:54:00
7#
您好,已经上传测试的页面代码,开发环境是win2008R2+vs2010+IE8。

我用的Demo中的后台导出的代码是有Txt和CSV的,为什么JS导出不支持呢?

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
回复 使用道具 举报
roger.wang
社区贡献组   /  发表于:2014-5-26 17:42:00
8#
回复 7楼yf182187239的帖子

我找了一个demo:
可以WebViewer1.LocateDataSource、前台导出


运行需要加载AR V8的dll

参考博客:http://blog.gcpowertools.com.cn/ ... urce_SubReport.aspx

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
回复 使用道具 举报
yf182187239
中级会员   /  发表于:2014-5-27 09:32:00
9#
您好,您给的Demo和我的代码实现原理基本一样,都是可以实现报表的赋值和导出的,现在的问题是在btn_Excel_OnClick事件中给报表实例赋值时不执行赋值方方法,代码如下:
protected void btnExcel_Click(object sender, EventArgs e)
        {
            GrapeCity.ActiveReports.PageReport _reportDef = new GrapeCity.ActiveReports.PageReport(new System.IO.FileInfo(Server.MapPath("../") + "Reports/1.rdlx"));
            _reportDef.Document.LocateDataSource += WebViewer1_LocateDataSource;
            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=客户订单.xlsx"));
            Response.BinaryWrite(ms.ToArray());
            Response.End();
        }
回复 使用道具 举报
roger.wang
社区贡献组   /  发表于:2014-5-27 12:28:00
10#
回复 9楼yf182187239的帖子

在导出Excel的时候,LocateDataSource调用的顺序见下图:

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
回复 使用道具 举报
12下一页
您需要登录后才可以回帖 登录 | 立即注册
返回顶部