String filetype = "";
Filetype = ddlfiletype. selectedvalue;
String contenttype = "";
String myfilename = request. mappath (".") + "file: // reportexportfile //" + session. sessionid + "." + filetype;
Crystaldecisions. Shared. diskfiledestinationoptions mydiskfiledestinationoptions = new crystaldecisions. Shared. diskfiledestinationoptions ();
Mydiskfiledestinationoptions. diskfilename = myfilename;
Crystaldecisions. Shared. exportoptions myexportoptions = myreport. exportoptions;
Myexportoptions. destinationoptions = mydiskfiledestinationoptions;
Myexportoptions. exportdestinationtype = crystaldecisions. Shared. exportdestinationtype. diskfile;
Switch (ddlfiletype. selecteditem. value)
{
Case "pdf ":
Contenttype = "application/pdf ";
Myexportoptions. exportformattype = crystaldecisions. Shared. exportformattype. portabledocformat;
Break;
Case "Doc ":
Response. contenttype = "application/MS-excel ";
Myexportoptions. exportformattype = crystaldecisions. Shared. exportformattype. wordforwindows;
Break;
Case "xls ":
Contenttype = "application/vnd. MS-excel ";
This. enableviewstate = false;
Myexportoptions. exportformattype = crystaldecisions. Shared. exportformattype. Excel;
Break;
}
Myreport. Export ();
Response. clearcontent ();
Response. clearheaders ();
Response. contenttype = contenttype;
Response. writefile (myfilename );
Response. Flush ();
Response. Close ();
system. Io. file. Delete (myfilename);