在 asp.net MVC 4.0中使用rdlc,求详细的代码,试网上的代码试吐了,也没有搞出来,我给高分
public ActionResult Index()
{
LocalReport localReport = new LocalReport();
localReport.ReportPath = Server.MapPath(@"~/Report/myDataSet.rdlc");
ReportDataSource reportDataSource = new ReportDataSource("MyDataSet", new FS_NEWEntities().T_Login.ToList());
localReport.DataSources.Add(reportDataSource);
string reportType = "PDF";
string mimeType = "application/pdf ";
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
);
return File(renderedBytes,mimeType);
}
http://www.cnblogs.com/waxdoll/category/49402.html?Show=All 很全
我已解决.............
public ActionResult Index() { LocalReport localReport = new LocalReport(); localReport.ReportPath = Server.MapPath(@"~/Report/myDataSet.rdlc"); ReportDataSource reportDataSource = new ReportDataSource("MyDataSet", new FS_NEWEntities().T_Login.ToList()); localReport.DataSources.Add(reportDataSource); string reportType = "PDF"; string mimeType = "application/pdf "; 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 ); return File(renderedBytes,mimeType); }
rdlc的数据类型与绑的数据类型要一致,。。。。。。。。试了n篇文章。看了一个视频才解决,真是太down了