....
LocalReport localReport = new LocalReport();
localReport.ReportPath = @"c:\Users\sbencetic\Documents\Visual Studio 2012\Projects\WebApplication2\Report1.rdlc";
//ReportDataSource reportDataSource = new ReportDataSource("Customers", Customers.GetAllCustomers());
//localReport.DataSources.Add(reportDataSource);
string reportType = "Excel";
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);
Page.Response.BinaryWrite(renderedBytes);
No comments:
Post a Comment