MVC3怎么使用VS自带的.rdlc报表

2025-03-24 21:22:51
推荐回答(1个)
回答1:

LocalReport localReport = new LocalReport();
localReport.ReportPath = Server.MapPath("~/Controllers/Report/Report1.rdlc");
ReportDataSource reportDataSource = new ReportDataSource("DataSet1",db.authors.ToList());

localReport.DataSources.Add(reportDataSource);
string reportType = "PDF";
string mimeType;
string encoding;
string fileNameExtension;
string deviceInfo =
"" +
" PDF" +
" 8.5in" +
" 11in" +
" 0.5in" +
" 1in" +
" 1in" +
" 0.5in" +
"
";
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);