Writing Code
 Crystal Reports Forum : Crystal Reports .NET 2003 : Writing Code
Message Icon Topic: Export Pdf Error Post Reply Post New Topic
Author Message
manimtech
Newbie
Newbie
Avatar

Joined: 02 Apr 2007
Location: India
Online Status: Offline
Posts: 2
Quote manimtech Replybullet Topic: Export Pdf Error
    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?


Edited by manimtech - 09 Apr 2007 at 4:10am
Subramanian @ Mani
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet 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>
IP IP Logged
manimtech
Newbie
Newbie
Avatar

Joined: 02 Apr 2007
Location: India
Online Status: Offline
Posts: 2
Quote manimtech Replybullet 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
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet 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>
IP IP Logged
abhashkr
Newbie
Newbie
Avatar

Joined: 24 Apr 2007
Location: India
Online Status: Offline
Posts: 5
Quote abhashkr Replybullet 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();

}



Edited by abhashkr - 24 Apr 2007 at 5:25am
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3701
Quote hilfy Replybullet 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
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.031 seconds.