Monday, August 31, 2009

How programmatically set Custom Page Size while exporting Crystal Report using VB.NET

How programmatically set Custom Page Size while exporting Crystal Report using VB.NET


You can easily set paper size with export functionality. Simply design crystal report as you do and bind it with database, dataset or any other data source.


When you export crystal report its takes paper size based on the crystal report design page size, if your requirement to display or print exported file in particular format then following code will help to do this.


Following example tested in


1) .NET Framework 2.0 and Visual Studio 2005

2) Crystal Report with Visual Studio 2005


DLL references requires


VB.NET Code


'Fill dataset as with desired data needs to populates crystal report
Dim dsReportOut As New DataSet
Dim rptDoc As New CrystalDecisions.CrystalReports.Engine.ReportDocument
Dim reportPath As String = "CrystalReportFilePath"
Dim fileName As String = "ExportFileName.doc"
'Build the report logic here. Declare a report document.
rptDoc = New CrystalDecisions.CrystalReports.Engine.ReportDocument()
rptDoc.Load(String.Concat(reportPath, "CrystalReportFileName.rpt"))
rptDoc.SetDataSource(dsReportOut)
'Set Paper Size as A4 its letter size
rptDoc.PrintOptions.PaperSize = CrystalDecisions.Shared.PaperSize.PaperLetter
--**(See below for other PaperSize options)
'Export crystal report into MSWord
rptDoc.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.WordForWindows, String.Concat(reportPath, fileName))
--***(See below for other Export Format Options)
'Open(Exported file)MSWord File
Dim ProcessStartInfo As New System.Diagnostics.ProcessStartInfo
ProcessStartInfo.FileName = String.Concat(reportPath, fileName)
ProcessStartInfo.WindowStyle = ProcessWindowStyle.Maximized
System.Diagnostics.Process.Start(ProcessStartInfo)

** Others PaperSize Options


*** Others Export Options


3 comments:

Anonymous said...

http://www.testriffic.com/user/Clyde1202/
[http://www.webmonkey.com/tutorial/Female_orgasm_frequency_age_viagra/ female orgasm frequency age viagra]
[url="http://www.webmonkey.com/tutorial/The_christmas/"]the christmas[/url]
[url="http://www.webmonkey.com/tutorial/Charles_dickens_christmas_carol/"]charles dickens christmas carol[/url]
[url="http://www.webmonkey.com/tutorial/Christmas_e_card/"]christmas e card[/url]
unique christmas gift for boyfriend
[url="http://www.webmonkey.com/tutorial/Christmas_carol_torrent/"]christmas carol torrent[/url]
http://www.webmonkey.com/tutorial/Christmas_card_idea_cricut/
[http://www.webmonkey.com/tutorial/Christmas_flower_poinsettias christmas flower arrangements]
[http://www.webmonkey.com/tutorial/Office_christmas_party_game/ office christmas party game]
[http://www.webmonkey.com/tutorial/Invitation_party_christmas_invitation/ invitation party christmas invitation]
[url="http://www.webmonkey.com/tutorial/Online_photo_christmas_card/"]online photo christmas card[/url]
http://www.webmonkey.com/tutorial/Cheap_christmas_gift_basket/
[http://www.webmonkey.com/tutorial/Christmas_gift_card_holder/ christmas gift card holder]

Anonymous said...

Top Internet sites
[url=http://cesdors.seite.st/68/map.html]bad mortgage credit j[/url]
[url=http://worcester.avafreehost.com/73/map.html]aveeno care eczema k[/url]
[url=http://worcester.avafreehost.com/53/index.html]augmentin as treatment 816[/url]
[url=http://kohlerengine.hostevo.com/49/index.html]complication an after i[/url]
[url=http://chewinggum.hostaim.com/79/index.html]success clomid overweight N[/url]
[url=http://corjogo.xn--nht-qla.de/58/index.html]market sovereign emerging i[/url]
[url=http://ceywokc.hot.lc/32/map.html]annual credit report map 769[/url]

We will be glad to see you

Anonymous said...

free personals for police officers [url=http://loveepicentre.com/]site couples dating finding fun minded[/url] united kingdom singles http://loveepicentre.com/ free datingsites with free membership