因为客户一直用VB6 调用Report2生成PDF和Excel,现在需要用MVC并且升级Report10. 现在开始抓头。。。。Report2里面的调用方式到.net都会出错。
帮忙看一下 我只是想添加PageHeader 并向里面添加一个label,其实添加不添加Label都会报错 会报一个索引越界的错误在 _rpt.Run(); 方法时。
- SectionReport _rpt = new SectionReport();
- _rpt.PrintWidth = 14400;
- _rpt.PageSettings.Margins.Bottom = 720;
- _rpt.PageSettings.Margins.Top = 720;
- _rpt.PageSettings.Margins.Right = 720;
- _rpt.PageSettings.Margins.Left = 720;
- _rpt.PageSettings.Orientation = GrapeCity.ActiveReports.Document.Section.PageOrientation.Landscape;
-
- var ph = new GrapeCity.ActiveReports.SectionReportModel.PageHeader();
- ph.CanGrow = true;
- ph.CanShrink = true;
- ph.Name = "PageHeader";
- _rpt.Sections.Add(ph);
- GrapeCity.ActiveReports.SectionReportModel.Label lable1 = new GrapeCity.ActiveReports.SectionReportModel.Label();
- ph.Controls.AddRange(new GrapeCity.ActiveReports.SectionReportModel.ARControl[] { lable1 });
- lable1.Name = "lblHeading";
- lable1.Text = "Users and Groups Report";
- lable1.Height = 300;
- lable1.Left = 0;
- lable1.Top = 0;
- lable1.Width = 3000;
- lable1.VerticalAlignment = GrapeCity.ActiveReports.Document.Section.VerticalTextAlignment.Middle;
- lable1.Alignment = GrapeCity.ActiveReports.Document.Section.TextAlignment.Left;
- lable1.Style = "font-family: arial; font-size:17pt; font-weight:bold; font-style:italic; color: black";
- lable1.BackColor = System.Drawing.Color.White;
- int nLabelTop = 355;
- ph.Visible = true;
- ph.Height = 100;
- //_rpt.Document.Name = "Users and Groups Report";
- _rpt.Run();
- string fileName = "C:\reports\new" + Guid.NewGuid().ToString() + ".pdf";
- GrapeCity.ActiveReports.Export.Pdf.Section.PdfExport PdfExport = new GrapeCity.ActiveReports.Export.Pdf.Section.PdfExport();
- PdfExport.Export(_rpt.Document, fileName);
复制代码 |
|