2293174034 发表于 2015-4-25 08:22:00

在测试中ViewerType类型为AcrobatReader时显示的报表效果较好

frank.zhang 发表于 2015-4-27 18:04:00

您好,
为了避免程序验证的复杂度。我们先在普通的ASP程序中实现了上述功能。


2293174034 发表于 2015-4-28 15:42:00

您好,
我在Microsoft Visual studio C# 2012+Asp.Net MVC4+ActiveReports+视图引擎Razor环境下作了一个小实例,
实例地址 http://pan.baidu.com/s/1eQvT370
主要问题如下:AcrobatReader类型报表预览效果较好
1、个人表40条记录无法分页,只显示第一页,如何处理?;
2、导出excel在aspx下是通过服务器端响应文件流方式处理的,在cshtml(Razor环境)下如何实现?
3、是否可以实现客户端直接导出excel\保存pdf\打印?
   比如在预览时打印按钮功能直接调用ActiveReportsWeb:WebViewer工具栏上的print按钮,保存pdf直接调用ActiveReportsWeb:WebViewer工具栏上的保存按钮。
4、HtmlViewer类型报表预览效果变型(实例中的花名册)?
5、FlashViewer类型报表无法预览?

iceman 发表于 2015-4-28 16:48:00

回复 13楼2293174034的帖子

问题正在处理中,稍后给您回复。

iceman 发表于 2015-4-28 17:20:00

回复 13楼2293174034的帖子

第一个问题,我这边的预览结果是:


已经分页了,是否是你希望的效果?

2293174034 发表于 2015-4-28 17:31:00

这是花名册可以分页,
单个人登记表只能显示第一个人的信息?

iceman 发表于 2015-4-28 17:34:00

回复 13楼2293174034的帖子

问题2 “导出excel在aspx下是通过服务器端响应文件流方式处理的,在cshtml(Razor环境)下如何实现?”

可以在 Controller 中添加Action 方法如下:
前台页面:

<ul>
    <li>@Html.ActionLink("Export Report", "Export")</li>   
</ul>


Controller 方法:

      public void Export()
      {
            ReportClass model = new ReportClass();
            Reports.SectionReport1 s_report = new Reports.SectionReport1();
            s_report.Run();

            System.IO.MemoryStream ms = new System.IO.MemoryStream();
            GrapeCity.ActiveReports.Export.Excel.Section.XlsExport xlsExport1 = new GrapeCity.ActiveReports.Export.Excel.Section.XlsExport(); xlsExport1.FileFormat = GrapeCity.ActiveReports.Export.Excel.Section.FileFormat.Xlsx;
            xlsExport1.Export(s_report.Document, ms);

            Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
            Response.AddHeader("content-disposition", Server.UrlPathEncode("attachment;filename=Test1.xlsx"));
            Response.BinaryWrite(ms.ToArray());            
      }

2293174034 发表于 2015-4-29 10:10:00

上面这种方法导出的Excel报表,效果很差,
无法显示报表中的表格线及背景色等格式

2293174034 发表于 2015-4-29 10:17:00

下面的方法在aspx下效果还可以,单在cshtml下导出时有错误提示 the data returned by LocateDataSource are null

_reportdata2 = GzxxData.GetRyjbxxs();
                  GrapeCity.ActiveReports.PageReport _reportDef = new GrapeCity.ActiveReports.PageReport(new FileInfo(Server.MapPath(&quot;/Reports/ryb/pyrydjb.rdlx&quot;)));
                                       
                  ((PageReport)(_reportDef)).Document.LocateDataSource += Document_LocateDataSource2;
                  _reportDef.Run();
                  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.Xlsx;
                  excelSetting.MultiSheet = false;
                  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());
                  
                  //outputProvider.GetPrimaryStream().OpenStream().CopyTo(ms);
                  //return File(ms.ToArray(), &quot;application/vnd.ms-excel&quot;, Url.Encode(&quot;ryjbxx.xlsx&quot;));
                  Response.ContentType = &quot;application/vnd.ms-excel&quot;;
                  Response.AddHeader(&quot;content-disposition&quot;, &quot;inline;filename=客户订单.xlsx&quot;);
                  outputProvider.GetPrimaryStream().OpenStream().CopyTo(ms);
                  Response.BinaryWrite(ms.ToArray());
                  Response.End();

frank.zhang 发表于 2015-4-29 12:06:00

您好,
我们怀疑是这个方法没有能够进去,导致的数据集是空的。
Document_LocateDataSource2
您可以打断电尝试下。
页: 1 [2] 3 4
查看完整版本: ActiveRepors+asp.netMvc4浏览器端打印导出问题