Asp.net-报表查看器以本地处理模式导出到图像
我用来在本地处理模式下导出为图像的以下代码在
Response.Buffer = true;
Response.Clear();
Response.ContentType = mimeType;
Response.AddHeader("content-disposition", "attachment; filename= hi." + "jpeg");
Response.BinaryWrite(byts);
Response.Flush();
Warning[] warnings;
string[] streamids;
string encoding;
string extension;
string mimeType = "image/png";'
string deviceInfo ="<DeviceInfo><OutputFormat>PNG</OutputFormat></DeviceInfo>";
byte[] byts = null;
byts = ReportViewer1.LocalReport.Render("Image", deviceInfo , out mimeType, out encoding, out extension, out streamids, out warnings);
Response.Buffer = true;
Response.Clear();
Response.ContentType = mimeType;
Response.AddHeader("content-disposition", "attachment; filename= hi." + "jpeg");
Response.BinaryWrite(byts);
Response.Flush();
这里代码工作正常,但它没有将完整的报告导出为图像,只有第一页导出为图像,我看不到第二页作为图像, 请帮帮我 预先感谢
Shanmugapriya.D
The following code i am using to export as a image in local processing mode is
Response.Buffer = true;
Response.Clear();
Response.ContentType = mimeType;
Response.AddHeader("content-disposition", "attachment; filename= hi." + "jpeg");
Response.BinaryWrite(byts);
Response.Flush();
Warning[] warnings;
string[] streamids;
string encoding;
string extension;
string mimeType = "image/png";'
string deviceInfo ="<DeviceInfo><OutputFormat>PNG</OutputFormat></DeviceInfo>";
byte[] byts = null;
byts = ReportViewer1.LocalReport.Render("Image", deviceInfo , out mimeType, out encoding, out extension, out streamids, out warnings);
Response.Buffer = true;
Response.Clear();
Response.ContentType = mimeType;
Response.AddHeader("content-disposition", "attachment; filename= hi." + "jpeg");
Response.BinaryWrite(byts);
Response.Flush();
here code is working fine, but it does not export the complete report as a image, only the first page is exporting as image, i could not see the second page as a image,
Please help me out
Thanks in advance
Shanmugapriya.D
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您只能从 ReportViewer 控件获取一页的图像。您可以做的是为所有页面生成图像 - 通过更改控件的
CurrentPage
属性或使用 渲染重载 需要 CreateStreamCallback 例如在这种情况下,Render 方法会不断调用回调,直到页面完成,因此您将获得
m_pages
集合填充了所有页面图像的数据。现在,您可能可以压缩所有这些图像并发送响应,或者您可以使用一些图像处理库将这些图像拼接在一起以形成一个大图像以返回(这不是一个好主意,因为它会给您的服务器带来相当大的负载)。通常,如果您要创建预览之类的东西,那么最好的办法是缓存这些图像并返回包含这些图像超链接的 html。
You can only get image for one page from ReportViewer control. What you can do is to generate images for all pages - either by changing
CurrentPage
property of the control or using the Render overload that takes CreateStreamCallback such asIn such case, Render method keeps calling on the call-back till on pages are finished and thus you will have your
m_pages
collection filled with data for all page images. Now, you can probably zip all those images and send across the response or you may use some image manipulation library to stitch those images together to form one big image to return back (not a good idea because it will put quite a load on your server).Typically, if you are going to create pre-view sort of thing then good idea would be to cache those images and return the html that would contain hyperlinks to those images.
尝试将 StartPage 元素添加到您的设备信息并将其设置为“0”。请参阅 http://msdn.microsoft.com/en-us/library/ms155373。 .aspx.
Try adding the StartPage element to your device info and set it to "0". See http://msdn.microsoft.com/en-us/library/ms155373.aspx.