Arijit Ghosh
Arijit Ghosh

Reputation: 1

Export to excel without server side storage

i want to export a gridview to excel directly on da client side....without storing on the server side as I don't have write access on Web server. May be memory stream can help in this scenario. So looking for suggestion.

Upvotes: 0

Views: 161

Answers (1)

mgmedick
mgmedick

Reputation: 700

Do you have a webpage that just displays the gridview? Or if the gridview is in a control then pop the control into an empty page. Then do something like this on that page. So if the "xls" is in the query string when the page is called, it should prompt the user to download the file. Not sure if this is what your looking for or not.

protected void Page_PreInit(object sender, EventArgs e)
{
    if (RequestStr("xls").IsNotEmpty())
    {
        this.MasterPageFile = "~/blankmaster.master";
        Response.ContentType = "application/vnd.ms-excel";
        Response.AppendHeader("content-disposition", "attachment; filename= somedownload.xls");
    }
}

This is all you would need to do to serve the web page as an excel file.

Upvotes: 1

Related Questions