RE: ReportViewer
- From: stcheng@xxxxxxxxxxxxxxxxxxxx (Steven Cheng [MSFT])
- Date: Fri, 20 Jun 2008 06:28:16 GMT
Hi Gerhard,
As for the Visual Studio ReportViewer control, it does support programmtic
exporting/saving the report content. Actually, it is done through the
LocalReport.Render method, this method can help you programmtically
generate the binary stream(byte array) of the report content. Here is a web
article mentioned this:
#How to render client report definition files (.rdlc) directly to the
Response stream without preview
http://weblogs.asp.net/rajbk/archive/2006/03/02/How-to-render-client-report-
definition-files-_28002E00_rdlc_2900_-directly-to-the-Response-stream-withou
t-preview.aspx
I've also written a simple example in VB.NET for your reference:
VB.NET sample
=========================
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs)
Handles Button1.Click
Dim reportType As String = "PDF"
Dim mimeType As String
Dim encoding As String
Dim fileNameExtension As String
'The DeviceInfo settings should be changed based on the reportType
'http://msdn2.microsoft.com/en-us/library/ms155397.aspx
Dim deviceInfo As String = "<DeviceInfo>
<OutputFormat>PDF</OutputFormat>
<PageWidth>8.5in</PageWidth><PageHeight>11in</PageHeight><MarginTop>0.5in</M
arginTop><MarginLeft>1in</MarginLeft><MarginRight>1in</MarginRight><MarginBo
ttom>0.5in</MarginBottom></DeviceInfo>"
Dim warnings As Warning()
Dim streams As String()
Dim renderedBytes As Byte()
'Render the report
renderedBytes = ReportViewer1.LocalReport.Render(reportType,
deviceInfo, mimeType, encoding, fileNameExtension, streams, warnings)
Dim fs As FileStream =
System.IO.File.Create("c:\temp\report_out.pdf")
fs.Write(renderedBytes, 0, renderedBytes.Length)
fs.Close()
====================================
Hope this helps.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@xxxxxxxxxxxxxx
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
From: =?Utf-8?B?R2VyaGFyZA==?= <Gerhard@xxxxxxxxxxxxxxxx>ReportViewer
Subject: ReportViewer
Date: Thu, 19 Jun 2008 15:39:03 -0700
I am using vb.net and asp.net version 3.5. I have a page with a
where I want to be able to programatically save the report in Excel formatin
a specified directory on the web server. Can you please point me tosample
code on how to do this?
Thanks.
.
- Follow-Ups:
- RE: ReportViewer
- From: Gerhard
- RE: ReportViewer
- Prev by Date: Re: asp.net 2.0 and Ajax
- Next by Date: Re: asp.net 2.0 and Ajax
- Previous by thread: Login Control Problem
- Next by thread: RE: ReportViewer
- Index(es):