Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

export crystal pdf to folder on server

Status
Not open for further replies.

cathiec

Programmer
Oct 21, 2003
139
IE
I export a crystal report to the solution folder at the moment. i want to export the reports to a folder called REPORTS on the server.

I use the following code to export the reports:



rptBuildByDate crReportDocument = new rptBuildByDate();
crReportDocument.SetDataSource(this.dstBuildPDF2);
string ExportPath;
ExportPath = Request.PhysicalApplicationPath;
crDiskFileDestinationOptions = new DiskFileDestinationOptions();
crExportOptions = crReportDocument.ExportOptions;

Session["filename"] = Session.SessionID.ToString() + ".pdf";


crDiskFileDestinationOptions.DiskFileName = ExportPath + Session["filename"].ToString();

crExportOptions.DestinationOptions = crDiskFileDestinationOptions;
crExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
crExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;

crReportDocument.Export();
Response.Redirect("Webform2.aspx");

//redirected to webform2 so that the browser back button
//will bring you back to the webform that the report
//is run from

webform2.aspx:

public class WebForm2 : System.Web.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here


string fName;
fName = Session["filename"].ToString();


Response.ClearContent();
Response.ClearHeaders();
Response.ContentType = "application/pdf";
Response.WriteFile(fName);
Response.Flush();
Response.Close();
}

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top