找回密码
 立即注册

QQ登录

只需一步,快速开始

lovezixue

高级会员

3

主题

7

帖子

1629

积分

高级会员

积分
1629
最新发帖
lovezixue
高级会员   /  发表于:2015-12-21 15:16  /   查看:4306  /  回复:4
因为客户一直用VB6 调用Report2生成PDF和Excel,现在需要用MVC并且升级Report10. 现在开始抓头。。。。Report2里面的调用方式到.net都会出错。

帮忙看一下 我只是想添加PageHeader 并向里面添加一个label,其实添加不添加Label都会报错 会报一个索引越界的错误在 _rpt.Run(); 方法时。
  1. SectionReport _rpt = new SectionReport();
  2.             _rpt.PrintWidth = 14400;
  3.             _rpt.PageSettings.Margins.Bottom = 720;
  4.             _rpt.PageSettings.Margins.Top = 720;
  5.             _rpt.PageSettings.Margins.Right = 720;
  6.             _rpt.PageSettings.Margins.Left = 720;
  7.             _rpt.PageSettings.Orientation = GrapeCity.ActiveReports.Document.Section.PageOrientation.Landscape;
  8.            

  9.             var ph = new GrapeCity.ActiveReports.SectionReportModel.PageHeader();
  10.             ph.CanGrow = true;
  11.             ph.CanShrink = true;
  12.             ph.Name = "PageHeader";
  13.             _rpt.Sections.Add(ph);


  14.             GrapeCity.ActiveReports.SectionReportModel.Label lable1 = new GrapeCity.ActiveReports.SectionReportModel.Label();

  15.             ph.Controls.AddRange(new GrapeCity.ActiveReports.SectionReportModel.ARControl[] { lable1 });
  16.             lable1.Name = "lblHeading";
  17.             lable1.Text = "Users and Groups Report";
  18.             lable1.Height = 300;
  19.             lable1.Left = 0;
  20.             lable1.Top = 0;
  21.             lable1.Width = 3000;
  22.             lable1.VerticalAlignment = GrapeCity.ActiveReports.Document.Section.VerticalTextAlignment.Middle;
  23.             lable1.Alignment = GrapeCity.ActiveReports.Document.Section.TextAlignment.Left;
  24.             lable1.Style = "font-family: arial; font-size:17pt; font-weight:bold; font-style:italic; color: black";
  25.             lable1.BackColor = System.Drawing.Color.White;
  26.             int nLabelTop = 355;
  27.             ph.Visible = true;
  28.             ph.Height = 100;


  29.             //_rpt.Document.Name = "Users and Groups Report";

  30.             _rpt.Run();
  31.             string fileName = "C:\reports\new" + Guid.NewGuid().ToString() + ".pdf";
  32.             GrapeCity.ActiveReports.Export.Pdf.Section.PdfExport PdfExport = new GrapeCity.ActiveReports.Export.Pdf.Section.PdfExport();
  33.             PdfExport.Export(_rpt.Document, fileName);
复制代码

4 个回复

倒序浏览
lovezixue
高级会员   /  发表于:2015-12-21 16:24:00
沙发
我发现把detail 和 pageFooter补上就不会报索引错误了,但是现在报另外一个错误
Additional information: Margins are too large
回复 使用道具 举报
lovezixue
高级会员   /  发表于:2015-12-21 16:51:00
板凳
把Margins值改小了,但是现在生成的PDF只显示“This document was created using an EVALUATION version of ActiveReports 10. Only a licensed user may legally create reports for use in production. Please report infractions or address questions to ActiveReports.Sales@grapecity.com. Copyright ©
2015 GrapeCity, inc. All rights reserved.”
我用的是Report10试用版 是用试用版无法开发吗?
回复 使用道具 举报
gw0506
超级版主   /  发表于:2015-12-22 17:56:00
地板
试用版30天内免费试用。这个提示应该是超时了。你什么时候安装的?
回复 使用道具 举报
ZenosZeng讲师达人认证 悬赏达人认证
超级版主   /  发表于:2015-12-23 09:26:00
5#
回复 3楼lovezixue的帖子

lovezixue 上午好,

我看到你使用代码动态创建报表模板,不知你这边的主要需求是什么,大概描述一下吧,我们可以共同讨论一个最适合你的视线方案。
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部