找回密码
 立即注册

QQ登录

只需一步,快速开始

fengyu77
银牌会员   /  发表于:2015-5-12 15:42:00
11#
回复 10楼frank.zhang的帖子

057181118729
回复 使用道具 举报
frank.zhang
社区贡献组   /  发表于:2015-5-12 16:01:00
12#
您好,
经过电话沟通,使用以下代码
  1. _reportDef.Report.DataSources[0].DataSourceReference = "";
  2.           _reportDef.Report.DataSources[0].ConnectionProperties.DataProvider = "SQL";
  3.           _reportDef.Report.DataSources[0].ConnectionProperties.ConnectString = "password=123456;data source=XA-PBD-FRANK;initial catalog=Test;user id=sa;";
复制代码

catalog是数据库名称

本帖子中包含更多资源

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

x
回复 使用道具 举报
fengyu77
银牌会员   /  发表于:2015-5-12 16:13:00
13#
回复 12楼frank.zhang的帖子

这样子还找不到数据吧,没有SQL的数据查询
回复 使用道具 举报
frank.zhang
社区贡献组   /  发表于:2015-5-12 17:33:00
14#
您好,
SQL的绑定是在设计进行绑定的。
回复 使用道具 举报
fengyu77
银牌会员   /  发表于:2015-5-13 08:43:00
15#
回复 14楼frank.zhang的帖子

但是现在的要求是这样的,我需要的是运行时绑定数据源,在导出的时候我似乎就没办法绑定数据了,在FlashViewer下我该怎么解决这个问题
回复 使用道具 举报
frank.zhang
社区贡献组   /  发表于:2015-5-13 09:43:00
16#
您好,
我对您的问题理解是,不仅需要动态绑定数据源,还需要动态绑定SQL语句。
动态绑定数据源的代码就是#12中所示例的代码。
动态绑定SQL使用
  1.             string productSql = string.Format("SELECT * From 产品 where 产品ID = {0}", productId);
  2.             _reportDef.Report.DataSets[0].Query.CommandText = productSql;
复制代码
回复 使用道具 举报
fengyu77
银牌会员   /  发表于:2015-5-13 15:32:00
17#
回复 16楼frank.zhang的帖子

很感谢你前面解决了我部分问题。
下面的问题是:以上讲的都是基于pagereport的导出,那么如果报表是基于代码、基于xml的该如何导出呢
回复 使用道具 举报
frank.zhang
社区贡献组   /  发表于:2015-5-13 16:15:00
18#
您好,
您想使用区域报表基于代码、区域报表基于xml导出为什么格式?也是excel吗?
回复 使用道具 举报
fengyu77
银牌会员   /  发表于:2015-5-13 16:33:00
19#
回复 18楼frank.zhang的帖子

是在做区域报表基于代码、基于Xml的导出时,我要如何绑定,就照前面的pagereport导出,代码我要如何写?
回复 使用道具 举报
frank.zhang
社区贡献组   /  发表于:2015-5-13 16:48:00
20#
您好,
区域报表基于代码的导出
  1.             Reports.SectionReport1 rpt = new Reports.SectionReport1();
  2.             rpt.Run();
  3.             GrapeCity.ActiveReports.Export.Excel.Section.XlsExport XlsExport1 = new GrapeCity.ActiveReports.Export.Excel.Section.XlsExport();
  4.             System.IO.MemoryStream ms = new System.IO.MemoryStream();
  5.             XlsExport1.FileFormat = GrapeCity.ActiveReports.Export.Excel.Section.FileFormat.Xlsx;
  6.             XlsExport1.Export(rpt.Document, ms);
  7.             ms.Position = 0;
  8.             Response.ContentType = "application/vnd.ms-excel";
  9.             Response.AddHeader("content-disposition", Server.UrlPathEncode("attachment;filename=MyExport.xlsx"));
  10.             Response.BinaryWrite(ms.ToArray());
  11.             Response.End();
复制代码

区域报表基于XML的导出
  1.             GrapeCity.ActiveReports.SectionReport sr = new GrapeCity.ActiveReports.SectionReport();
  2.             System.Xml.XmlTextReader xtr = new System.Xml.XmlTextReader(Server.MapPath("") + "\\Reports\\RP_YN_YarnSalesSummary.rpx");
  3.             sr.LoadLayout(xtr);
  4.             xtr.Close();
  5.             GrapeCity.ActiveReports.Export.Excel.Section.XlsExport XlsExport1 = new GrapeCity.ActiveReports.Export.Excel.Section.XlsExport();
  6.             System.IO.MemoryStream ms = new System.IO.MemoryStream();
  7.             XlsExport1.FileFormat = GrapeCity.ActiveReports.Export.Excel.Section.FileFormat.Xlsx;
  8.             XlsExport1.Export(sr.Document, ms);
  9.             ms.Position = 0;
  10.             Response.ContentType = "application/vnd.ms-excel";
  11.             Response.AddHeader("content-disposition", Server.UrlPathEncode("attachment;filename=MyExport.xlsx"));
  12.             Response.BinaryWrite(ms.ToArray());
  13.             Response.End();
复制代码
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部