首页 新闻 会员 周边

将RDLC数据在页面上显示

0
悬赏园豆:15 [已解决问题] 解决于 2012-04-01 17:44

下面是方法

 public static byte[] GenerateReport(string dtatSetName, IEnumerable dataSource, string reportFilePath,
string reportType, out string mimeType, out string encoding, out string fileNameExtension)
{
//报表数据源
ReportDataSource reportDataSource = new ReportDataSource(dtatSetName, dataSource);
//本地化报表
LocalReport localReport = new LocalReport();
localReport.ReportPath = reportFilePath;
localReport.DataSources.Add(reportDataSource);

string deviceInfo =
"<DeviceInfo>" +
" <OutputFormat>" + reportType + "</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;

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

return renderedBytes;
}

下面是Action

 public ActionResult EmployeesNumberPerYear()
{
string dtatSetName = "DsENPerYear";
var dataSource = EmployeeReports.EmployeesNumberPerYear(employeeRepository);
string reportFilePath = Server.MapPath("~/RDLC/Employee/EmployeesNumberPerYear.rdlc");
string reportType = "excel";

string mimeType;
string encoding;
string fileNameExtension;

byte[] renderedBytes = HotelReport.GenerateReport(dtatSetName, dataSource, reportFilePath,
reportType, out mimeType, out encoding, out fileNameExtension);
return File(renderedBytes, mimeType);
}

然而如果执行这个action数据会直接生成excel文件或pdf形式来返回,我想有一种预览的形式将这种byte数据显示到某个div当中,如果需要打印或生成的时候才返回一个文件。那么在jquery的请求和数据显示怎么弄呢?

凡一二三的主页 凡一二三 | 初学一级 | 园豆:85
提问于:2012-03-31 09:34
< >
分享
最佳答案
0

Response.Write不行?

收获园豆:15
OOLi | 初学一级 |园豆:163 | 2012-03-31 12:21
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册