Wednesday, February 4, 2009

How to render the Report to PDF/EXCEL format

I had a client who wanted to get his report directly to PDF file. Previously, he used to use a Report Viewer component in application and then exporting it to the appropriate format.
In this example I render my report to the PDF file that will be located on disk C:\.
This report also accepts one parameter.The key of the module is ReportExecutionService class which contains some methods that we need to use.

Please refer to the BOL


Imports Microsoft.SqlServer.ReportingServices2005

Private Sub CreatePdfFile()
Dim Res As New Execution.ReportExecutionService
Dim params(0) As Execution.ParameterValue
Res.Credentials = System.Net.CredentialCache.DefaultCredentials
Res.Url = "http://servername/ReportServer/ReportExecution2005.asmx?wsdl"
params(0) = New Execution.ParameterValue
params(0).Name = "ParamName"
params(0).Value = Value

Dim ReportPath As String = "/Reports/ReportName"

Res.LoadReport(ReportPath, Nothing)
Dim Format As String = "PDF"
Dim devInfo As String = Nothing
Dim extension As String = Nothing
Dim mimeType As String = Nothing
Dim encoding As String = Nothing
Dim warnings() As Execution.Warning = Nothing
Dim stremIds() As String = Nothing
Dim result() As Byte = Nothing
Res.SetExecutionParameters(params, "en-us") --ParameterLanguage

result = Res.Render(Format, devInfo, extension, mimeType, encoding, warnings, stremIds)
IO.File.WriteAllBytes("C:\Report.pdf", result)
End Sub


Anonymous said...

Even it got me crazy enough to buy Guild Wars Prophecies with some my own GuildWars Gold and Nightfall and Eye of the North. I wonder to know why are not you guys and gals who like the PVP concept buying this awesome game. okey, it is expensive to buy gw gold all parts. If you lack the GuildWars money, but it is worth it and no monthly costs and the game gets updated weekly at least. Once again, if anyone wants to play Guild Wars sometime add me to friends here Guild Wars Gold. And realize how much cheap gw gold I bought in the last couple of weeks, months, years. So I found this Guild Wars Factions and installed it.

Anonymous said...

China Wholesale has been described as the world’s factory. This phenomenom is typified by the rise ofbusiness. Incredible range of products available with China Wholesalers “Low Price and High Quality” not only reaches directly to their target clients worldwide but also ensures that wholesale from china from China means margins you cannot find elsewhere and buy products wholesaleChina Wholesale will skyroket your dressescheap naruto cosplayanime cosplay

Anonymous said...

Women’s nike tn Shox Rivalry est le modèle féminin le plus tendance de baskets pour le sport. tn chaussuresConcernant la semelle :spyder jacketsCheap Brand Jeans Shop - True Religion Jeans cheap nike shox & Puma Shoes Online- tn nike,Diesel Jeans le caoutchouc extérieur, l’EVA intermédiaire Levis Jeanset le textile intérieur s’associent pour attribuer à la.ed hardy shirts pretty fitCharlestoncheap columbia jackets. turned a pair of double plays to do the trick.Lacoste Polo Shirts, puma basket, Burberry Polo Shirts.wholesale Lacoste polo shirts and cheap polo shirtswith great price.Thank you so much!!cheap polo shirts men'ssweate,gillette mach3 razor bladesfor men.As for Cheap Evisu JeansCheap Armani Jeanspolo shirtsPuma shoes

aiya said...

Office 2010is powerful!
Microsoft Office 2010is the best software in the world.
Microsoft wordis so great!
Office 2007makes life great!
Many people likeMicrosoft Office.
Microsoft Office 2007is welcomed by the whole world.
Office 2007 keyis available here.
Office 2007 downloadis on sale now!
Office 2007 Professionalbring me so much convenience.
Outlook 2010 make life wonderful!
Microsoft outlook is my love.
Microsoft outlook 2010 is convenient!
Windows 7 is convenient!

rscredits said...

If a job is worth doing it is worth doing well.What runescape gold you share here just prove this saying, i like your thought here, rs gold which is special and informative.

This topic is pretty good and the writer's views are buy runescape gold unique and not so hard to understand.I like it very much, and by the cheap rs gold way I want to share some interesting and very useful websites to! Iam sure you can find out funny things there.

dolinna said...

That is really cool. Thanks for finding it. Some really good ideas there, this is going to be a real time sink. I am a china tour lover,You can learn more: China tour packages | China travel packages | China Travel Agency

Anonymous said...

You laugh at me for being different, but I laugh at you for being the same LOTRO Gold, the consequences of today are determined by the actions of the past Lord Of The Rings Gold, to change your future,LOTRO Gold alter your decisions today.

Learn Chinese language on hanbridgemandarin said...

Hanbridge has adopted a structured and interactive educational approach to enable you to learn Mandarin effectively and reach your targeted proficiency level. Clear pronunciation, the proper use of tones, real-life topics, and bilingual instruction all combine to ensure you will be able to communicate effectively.

More Chinese learning tags : how to learn Chinese | learn to speak Chinese | mandarin Chinese

Unknown said...

Nice article, thanks for the information. It's very complete information. I will bookmark for next reference
jaring futsal | jaring golf | jaring pengaman proyek |
jaring pengaman bangunan | jaring pengaman gedung

Unknown said...

Totally got a kick out of the above comments. Isn't the internet such a wonderful place?