client|web| programs in a Web application, we can't export reports as we would in a Windows application, because the program is executed on the server side, and the result is on the server side when the export is performed, how do you implement the full client export? Actually this is not difficult, the method is to specify that the report be exported to a previously established report staging file on a Web site, and then use the Response.Redirect () directive to point the browser URL to the report location so that the user's browser will try to download the newly exported file and the file will be downloaded to the client In order to achieve the results we need. Some of the code is as follows:
public string Exportreport ()
{
Exportoptions Creo = new Exportoptions ();
Diskfiledestinationoptions Crdo = new Diskfiledestinationoptions ();
String FileName = Request.physicalapplicationpath + "Exportfile\exap.xls";
Set export options
Creo = myrpt.exportoptions;
Creo. Exportformattype = Exportformattype.excel;
Creo. Exportdestinationtype = Exportdestinationtype.diskfile;
Set Disk File options
Crdo. Diskfilename = FileName;
Creo. Destinationoptions = Crdo;
Export Report
Myrpt.export ();
return FileName;
}
private void Buttonexport_click (object sender, System.EventArgs e)
{
String FileName = Exportreport ();
Response.Redirect (Replace (Filename,request.physicalapplicationpath + "exportfile\", ""));
}
Note that when exporting to the web, you need to have permissions to establish files on the exported directory, and if there is insufficient permissions, the error "Deny access to the report file ..." will appear. Let the ASPNET user (the system user that is automatically generated when the. NET framework is installed) have the Write permission in the export directory text.