How to enable Web applications to export report functionality on the client side

Source: Internet
Author: User
Tags client
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.




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.