Print Page | Close Window

Export Pdf Error

Printed From: Crystal Reports Book
Category: Crystal Reports .NET 2003
Forum Name: Writing Code
Forum Discription: .NET 2003 programming API, report integration
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=483
Printed Date: 16 May 2024 at 7:35pm


Topic: Export Pdf Error
Posted By: manimtech
Subject: Export Pdf Error
Date Posted: 09 Apr 2007 at 4:09am

rptDoc = new ReportDocument();

rptDoc.Load(Server.MapPath("myReport.rpt"));

 
diskOpt = new DiskFileDestinationOptions();

diskOpt.DiskFileName = "C:\report.pdf";

expOpt = new ExportOptions();

expOpt.ExportDestinationType = ExportDestinationType.DiskFile;

expOpt.ExportFormatType = ExportFormatType.PortableDocFormat;

expOpt.ExportDestinationOptions = diskOpt;

expOpt.ExportFormatOptions = pdfOpt;

rptDoc.Export(expOpt); // Missing Parameter..

The above code showed error what will i do?


-------------
Subramanian @ Mani



Replies:
Posted By: BrianBischof
Date Posted: 09 Apr 2007 at 11:26am
Well, my first question is, "Does the report have parameters?" It appears so from the error message. Gotta write the code to populate the parameters before doing the export.

-------------
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>


Posted By: manimtech
Date Posted: 09 Apr 2007 at 9:22pm
Hai Good morning..
Thanks for ur kind reply..
already i have passed parameter and got crystal report print ..
after that..i need to export pdf file ..
 
Note : Kindly see the below coding
 

protected void btnViewReport(object sender, EventArgs e)

{

ParameterFields paramFields = new ParameterFields();

ParameterField paramField = new ParameterField();

ParameterDiscreteValue discreteValue = new ParameterDiscreteValue();

paramField.ParameterFieldName = "Name";

discreteValue.Value = txtName.Text;

paramField.CurrentValues.Add(discreteValue);

paramFields.Add(paramField);

CrystalReportViewer1.ParameterFieldInfo = paramFields;

CrystalReportViewer1.ReportSource = rptDoc;

CrystalReportViewer1.DataBind();

}

protected void btnExportPDF_Click(object sender, EventArgs e)

{

rptDoc = new ReportDocument();

rptDoc.Load(Server.MapPath("myReport.rpt"));

diskOpt = new DiskFileDestinationOptions();

diskOpt.DiskFileName = "C:\report.pdf";

expOpt = new ExportOptions();

expOpt.ExportDestinationType = ExportDestinationType.DiskFile;

expOpt.ExportFormatType = ExportFormatType.PortableDocFormat;

expOpt.ExportDestinationOptions = diskOpt;

expOpt.ExportFormatOptions = pdfOpt;

rptDoc.Export();

}



-------------
Subramanian @ Mani


Posted By: BrianBischof
Date Posted: 09 Apr 2007 at 9:49pm
I see. Crystal Reports doesn't share data between the report object and the viewer. You have to either set all properties using the report object or all properties using the viewer object. But not both. If you try to use both (as you are doing) CR will default to using the properties of the report object and ignore any settings of the viewer object. That's why it doesn't see the parameter values you added.

It's best to stick with the report object because it is more robust. The viewer object only has minimal properties available.


-------------
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>


Posted By: abhashkr
Date Posted: 24 Apr 2007 at 5:24am

protected void btnExportPDF_Click(object sender, EventArgs e)

{

rptDoc = new ReportDocument();

rptDoc.Load(Server.MapPath("myReport.rpt"));

diskOpt = new DiskFileDestinationOptions();

diskOpt.DiskFileName = "C:\report.pdf";

expOpt = new ExportOptions();

expOpt.ExportDestinationType = ExportDestinationType.DiskFile;

expOpt.ExportFormatType = ExportFormatType.PortableDocFormat;

expOpt.ExportDestinationOptions = diskOpt;

expOpt.ExportFormatOptions = pdfOpt;where pdfOpt declare

rptDoc.Export();

}



Posted By: hilfy
Date Posted: 26 Apr 2007 at 9:18am

Also, your code is loading a new report document instead of working with the report that's already in your viewer.  That's why you are seen the parameter error - you may have set the parameters in the viewer, but you haven't set them for this new report document object.  It doesn't matter if they're both loading the same report file, they're two completely separate objects at this point and you have to set all of the properties for both.

-Dell


-------------
Proviti, Data & Analytics Practice
http://www.protiviti.com/US-en/data-management-advanced-analytics - www.protiviti.com/US-en/data-management-advanced-analytics



Print Page | Close Window