簡體   English   中英

使用rdlc在asp.net mvc中沒有報告顯示

[英]No report display in asp.net mvc using rdlc

我正在嘗試使用以下代碼顯示報告,很遺憾,沒有任何顯示或下載。

public ActionResult DetailsReport()
        {

            LocalReport localReport = new LocalReport();
            localReport.ReportPath = Server.MapPath("~/Content/Reports/Data.rdlc");
            ReportDataSource reportDataSource = new ReportDataSource("dsData", GetAllData());

            localReport.DataSources.Add(reportDataSource);
            string reportType = "PDF";
            string mimeType;
            string encoding;
            string fileNameExtension;

            //The DeviceInfo settings should be changed based on the reportType
            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=Data." + fileNameExtension);
            return File(renderedBytes, mimeType);


        }

 public static List<vwDataReport> GetAllData()
        {
            var entities = new DataEntities();
            var x = from c in entities.vwDataReport
                    select c;
            return x.ToList();
        }

只需注釋以下行,然后重建項目。

Response.AddHeader("content-disposition", "attachment; filename=Data." + fileNameExtension);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM