【问题标题】:Rdlc in ASP.NET MVC does not render properlyASP.NET MVC 中的 Rdlc 无法正确呈现
【发布时间】:2012-08-01 18:27:16
【问题描述】:

我正在使用 ASP.NET MVC,我想在视图中呈现 rdlc。 这是我渲染 rdlc 文件的代码。

[HttpPost]
        public ActionResult DepartmentwiseInwardOutwardReport(int? fd, int? td, string fdt, string tdt)
        {
            TrackBL trackBL = new TrackBL();
            IEnumerable<TrackModel> trackList = trackBL.GetDeptInwardOutwardReport(fd, td, fdt, tdt);
            //return PartialView("_TrackingSearchReport", trackList);
            LocalReport localReport = new LocalReport();
            localReport.ReportPath = Server.MapPath("~/Content/Reports/FileMovement.rdlc");
            ReportDataSource reportDataSource = new ReportDataSource("Customers", trackList);
            reportDataSource.Name = "FTSDataSet_proc_File_InwardOutWardReport";
            localReport.DataSources.Add(reportDataSource);
            string reportType = "PDF";
            string mimeType;
            string encoding;
            string fileNameExtension;


            //The DeviceInfo settings should be changed based on the reportType
            //http://msdn2.microsoft.com/en-us/library/ms155397.aspx

            string deviceInfo =
            "<DeviceInfo>" +
            "  <OutputFormat>PDF</OutputFormat>" +
            "  <PageWidth>8.5in</PageWidth>" +
            "  <PageHeight>11in</PageHeight>" +
            "  <MarginTop>0.5in</MarginTop>" +
            "  <MarginLeft>1in</MarginLeft>" +
            "  <MarginRight>1in</MarginRight>" +
            "  <MarginBottom>0.5in</MarginBottom>" +
            "</DeviceInfo>";



            Warning[] warnings;
            string[] streams;
            byte[] renderedBytes;

            //Render the report
            renderedBytes = localReport.Render(
                reportType,
                deviceInfo,
                out mimeType,
                out encoding,
                out fileNameExtension,
                out streams,
                out warnings);

            //Response.AddHeader("content-disposition", "attachment; filename=NorthWindCustomers." + fileNameExtension);
            return File(renderedBytes, mimeType);

当我在视图中渲染它时,我可以看到 14 页,我现在只有 1 行可以显示。两列各显示在页面中。我想像报告一样显示它,其中所有列都显示在其他列旁边。 我错过了一些设置吗?有什么建议吗?

【问题讨论】:

    标签: c# asp.net-mvc rdlc


    【解决方案1】:

    我在 MVC3 甚至 MVC4 中使用 RDLC,我没有你面临的那个问题,即使我认为它与 RDLC 报告本身有关,也许你的页面宽度非常高,所以它会将它扭曲到 14页面(如果我忘记设置方向并且我有大量列,有时它会扭曲到 3 页。

    如果您将报告的宽度设置为大于您尝试打​​印的页面,则报告将自动拆分以适合页面。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-01-16
      • 2011-12-20
      • 2012-09-14
      • 2013-12-22
      • 1970-01-01
      • 2015-12-30
      • 2014-03-19
      • 2015-03-18
      相关资源
      最近更新 更多