Click here to Skip to main content
15,303,572 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all.

I am working in crystal reports and as all of us know, it has so many output formats such as: Excel, pdf, rpt, etc.

I want to control the format.

I mean that I want to execute the report as pdf for example.
How is this done?

Please help.
Posted
Updated 21-Nov-10 22:03pm
v3
Comments
Dalek Dave 22-Nov-10 4:03am
   
Edited for Spelling, Syntax and Readability

   
Comments
moon2011 21-Nov-10 4:23am
   
first, thanks alot
but i need it in C# not in VB
Sandeep Mewara 21-Nov-10 4:34am
   
1. You should be able to get how to do from it, it should be enough
2. There are lots of online free converters (VB to C#)
Dalek Dave 22-Nov-10 4:03am
   
Good link.
thanks

for helping other people, i found also this code for pdf

XML
ExportOptions CrExportOptions;
cryRpt = new ReportDocument();
string strReportPath = "CrystalReport2.rpt";
cryRpt.Load(Server.MapPath(strReportPath));

DiskFileDestinationOptions CrDiskFileDestinationOptions = new DiskFileDestinationOptions();
PdfRtfWordFormatOptions CrFormatTypeOptions = new PdfRtfWordFormatOptions();
CrDiskFileDestinationOptions.DiskFileName = "D:\\informations.pdf";
CrExportOptions = cryRpt.ExportOptions;
{
    CrExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
    CrExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;
    CrExportOptions.DestinationOptions = CrDiskFileDestinationOptions;
    CrExportOptions.FormatOptions = CrFormatTypeOptions;
}
cryRpt.Export();


and for excel format i found,

C++
ExportOptions CrExportOptions;
        cryRpt = new ReportDocument();
        string strReportPath = "CrystalReport2.rpt";
        cryRpt.Load(Server.MapPath(strReportPath));
        DiskFileDestinationOptions CrDiskFileDestinationOptions = new DiskFileDestinationOptions();
        ExcelFormatOptions CrFormatTypeOptions = new ExcelFormatOptions();
        CrDiskFileDestinationOptions.DiskFileName = "D:\\informations.xls";
        CrExportOptions = cryRpt.ExportOptions;
        CrExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
        CrExportOptions.ExportFormatType = ExportFormatType.Excel;
        CrExportOptions.DestinationOptions = CrDiskFileDestinationOptions;
        CrExportOptions.FormatOptions = CrFormatTypeOptions;
        cryRpt.Export();
   
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900