Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 31st, 2007, 06:52 AM
Authorized User
 
Join Date: Aug 2007
Location: mumbai, maharashtra, India.
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default Code for Exporting Crystal Report to Excel or PDF

hi,
This is Shakti. I work as a Software Programmer.
I have seen that most of young programmers search for code to Export a Crystal Report to different Formats. So here their search comes to an end.



ReportDocument rd = new ReportDocument();
rd.SetDataSource(dt);
// Here i have considered that rd has been set with DataTable dt as its SetDataSource property.
// Hence forth the code to Export the Crystal Report to other formats starts.

ExportOptions ex = new ExportOptions();
DiskFileDestinationOptions destinationURL = new DiskFileDestinationOptions();
ExcelFormatOptions formatOptionEXCEL = new ExcelFormatOptions();
destinationURL.DiskFileName = "..//report.xls";
ex.ExportDestinationType = ExportDestinationType.DiskFile;
ex.ExportFormatType = ExportFormatType.Excel;
ex.ExportDestinationOptions = destinationURL;
ex.ExportFormatOptions = formatOptionEXCEL;
rd.Export(ex);

//The above code exports the Crystal Report to Excel
//Similarly you can export Crystal Reports to PDF

ExportOptions ex = new ExportOptions();
DiskFileDestinationOptions destinationURL = new DiskFileDestinationOptions();
PdfRtfWordFormatOptions formatOptionPDF = new PdfRtfWordFormatOptions();
destinationURL.DiskFileName = "..//report.pdf";
ex.ExportDestinationType = ExportDestinationType.DiskFile;
ex.ExportFormatType = ExportFormatType.PortableDocFormat;
ex.ExportDestinationOptions = destinationURL;
ex.ExportFormatOptions = formatOptionPDF;
rd.Export(ex);
__________________
Software Programmer (ASP.NET),
Mumbai,
India.
  #2 (permalink)  
Old October 4th, 2007, 01:00 AM
Registered User
 
Join Date: Oct 2007
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Shakti,

Hope u are doing fine.
I tried your code but it gives me the following error:
Server Error in '/Ultrabot7' Application.
--------------------------------------------------------------------------------

Method 'ISCREditableRTFExportFormatOptions_reserved5' on type 'CrystalDecisions.ReportAppServer.ReportDefModel.E ditableRTFExportFormatOptionsClass' from assembly 'CrystalDecisions.ReportAppServer.ReportDefModel, Version=11.0.3300.0, Culture=neutral, PublicKeyToken=692fbea5521e1304' is overriding a method that has been overridden.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.TypeLoadException: Method 'ISCREditableRTFExportFormatOptions_reserved5' on type 'CrystalDecisions.ReportAppServer.ReportDefModel.E ditableRTFExportFormatOptionsClass' from assembly 'CrystalDecisions.ReportAppServer.ReportDefModel, Version=11.0.3300.0, Culture=neutral, PublicKeyToken=692fbea5521e1304' is overriding a method that has been overridden.

Source Error:


Line 57: ex.ExportDestinationOptions = destinationURL;
Line 58: ex.ExportFormatOptions = formatOptionEXCEL;
Line 59: mainReportDocument.Export(ex);
Line 60:
Line 61: }

.......

here is my code:
[[[[[[[[[[[[[[[[
mainReportPath = "../Reporting/Templates/UsersExportList.rpt";
                    mainReportDocument = new CrystalDecisions.CrystalReports.Engine.ReportDocum ent();
                    mainReportDocument.Load(Server.MapPath(mainReportP ath));


                    ExportOptions ex = new ExportOptions();
                    DiskFileDestinationOptions destinationURL = new DiskFileDestinationOptions();
                    ExcelFormatOptions formatOptionEXCEL = new ExcelFormatOptions();
                    destinationURL.DiskFileName = "..//report.xls";
                    ex.ExportDestinationType = ExportDestinationType.DiskFile;
                    ex.ExportFormatType = ExportFormatType.Excel;
                    ex.ExportDestinationOptions = destinationURL;
                    ex.ExportFormatOptions = formatOptionEXCEL;
                    mainReportDocument.Export(ex);

]]]]]]]]]]]]]]]]]]]]]]

please help me where i am wrong.
Best Regards
Waseem

Quote:
quote:Originally posted by shakti_2505270
 hi,
This is Shakti. I work as a Software Programmer.
I have seen that most of young programmers search for code to Export a Crystal Report to different Formats. So here their search comes to an end.



ReportDocument rd = new ReportDocument();
rd.SetDataSource(dt);
// Here i have considered that rd has been set with DataTable dt as its SetDataSource property.
// Hence forth the code to Export the Crystal Report to other formats starts.

ExportOptions ex = new ExportOptions();
DiskFileDestinationOptions destinationURL = new DiskFileDestinationOptions();
ExcelFormatOptions formatOptionEXCEL = new ExcelFormatOptions();
destinationURL.DiskFileName = "..//report.xls";
ex.ExportDestinationType = ExportDestinationType.DiskFile;
ex.ExportFormatType = ExportFormatType.Excel;
ex.ExportDestinationOptions = destinationURL;
ex.ExportFormatOptions = formatOptionEXCEL;
rd.Export(ex);

//The above code exports the Crystal Report to Excel
//Similarly you can export Crystal Reports to PDF

ExportOptions ex = new ExportOptions();
DiskFileDestinationOptions destinationURL = new DiskFileDestinationOptions();
PdfRtfWordFormatOptions formatOptionPDF = new PdfRtfWordFormatOptions();
destinationURL.DiskFileName = "..//report.pdf";
ex.ExportDestinationType = ExportDestinationType.DiskFile;
ex.ExportFormatType = ExportFormatType.PortableDocFormat;
ex.ExportDestinationOptions = destinationURL;
ex.ExportFormatOptions = formatOptionPDF;
rd.Export(ex);
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Exporting Crystal Report To Excel mohithmohith VB.NET 1 July 12th, 2008 12:36 AM
Problem in exporting crystal report to excel. yasinirshad .NET Framework 1.x 0 June 11th, 2008 02:20 AM
problem in Exporting Crystal report to PDF cat_net Crystal Reports 0 October 3rd, 2005 11:49 PM
Exporting Crystal Report to PDF vishal.jayaswal .NET Web Services 0 December 30th, 2004 03:31 AM
Exporting Crystal Report 6 RPT file into PDF forma ravs1304 Crystal Reports 2 December 29th, 2004 12:48 PM



All times are GMT -4. The time now is 09:13 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.