export grid view to excel  then compress to zip

Posted on 2011-10-25
Last Modified: 2012-09-18
hello all of you ,
i am trying to export grid view to excel then compress it to zip
here is the code of exporting to excel
any help to compress it to zip ?????
public void ExportGridViewToExcel(HttpResponse Response, GridView GridView_Excel)

        string attachment = "attachment; filename=Transactions.xls";


        Response.AddHeader("content-disposition", attachment);
        // Response.ContentEncoding = System.Text.Encoding.UTF7;
        Response.Charset = "";
        Response.ContentType = "application/ms-excel";

        StringWriter sw = new StringWriter();

        HtmlTextWriter htw = new HtmlTextWriter(sw);





Open in new window

Question by:AhmedHindy
    LVL 28

    Accepted Solution

    Instead of writing the stream writer to the response stream, you will have to write it to a file on the server and then use somehting like GZip to compress it and send the zip file to the response stream -

    I'm not sure, but you may be able to use GZip directly on the sw object and compress the stream in memory instead of writing to the disk. The example also shows displaying the data to a textbox, but you can take and send the GZip stream to the response.
    LVL 4

    Author Comment

    This will help in windows applications
    i want to use it in
    any help

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
    A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

    794 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now