Quantcast
Channel: Visual Studio Integrate forum
Viewing all articles
Browse latest Browse all 4410

Export to excel from Restful service

$
0
0

Hi folks, I have written a Restful service and consuming the service using jquery.

I have written a piece of code to export to excel in the restful code but when we call this service,

application is not poping up the excel dialog window.

but if i add this piece of code in the aspx page its work fine. How can i make this code to work inside the service. Below is the code im using


 GridView gv = new GridView();
            gv.DataSource =fetch();
            gv.DataBind();
            Response.ClearContent();
            Response.Buffer = true;
            Response.AddHeader("content-disposition", "attachment; filename=test.xls");
            Response.ContentType = "application/ms-excel";
            Response.Charset = "";
            StringWriter sw = new StringWriter();
            HtmlTextWriter htw = new HtmlTextWriter(sw);
            gv.RenderControl(htw);
            Response.Output.Write(sw.ToString());
            Response.Flush();
            Response.End();




Viewing all articles
Browse latest Browse all 4410

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>