Hello Friends
I am creating one project in web application in which i used crystal report. now i want to make pdf file from crystal report and i have to send it through mail. basically for this i used following code.
try
{
ExportOptions CrExportOptions;
DiskFileDestinationOptions CrDiskFileDestinationOptions = new DiskFileDestinationOptions();
PdfRtfWordFormatOptions CrFormatTypeOptions = new PdfRtfWordFormatOptions();
CrDiskFileDestinationOptions.DiskFileName = pdfFile;
CrExportOptions = ReportDocument .ExportOptions;//Report document object has to be given here
CrExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
CrExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;
CrExportOptions.DestinationOptions = CrDiskFileDestinationOptions;
CrExportOptions.FormatOptions = CrFormatTypeOptions;
ReportDocument .Export();
//sendmail();
}
catch (Exception ex)
{
//MessageBox.Show(ex.ToString());
}
all the other but i am geeting two error on two diff lines where i have make bold in the qustion.
this is the error for both .
An object reference is required for the non-static field, method, or property 'CrystalDecisions.CrystalReports.Engine.ReportDocument.Export()
For this i searched lot more things but i din't get proper solution.
please help me to solve the error.
Loading
Suthish NairPosted May 24, 2011, 5:11 AM
Save .pdf to a location programatically..
Crystal reports: Dynamically bind reports and export as PDF or any format
Link1
Link2 check point 6
omkar mhaiskarPosted May 24, 2011, 2:14 AM
but i m getting error. invalid file path.
I just want to generate file dynamically. i din't keep this file root folder also. i want to store dynamically generated file.
how can i store this?
Posted May 24, 2011, 2:04 AM
private void ExportToDisk (string fileName)
{
ExportOptions exportOpts = new ExportOptions();
DiskFileDestinationOptions diskOpts =
ExportOptions.CreateDiskFileDestinationOptions();
exportOpts.ExportFormatType = ExportFormatType.RichText;
exportOpts.ExportDestinationType =
ExportDestinationType.DiskFile;
diskOpts.DiskFileName = fileName;
exportOpts.ExportDestinationOptions = diskOpts;
Report.Export(exportOpts);
}