Click here to Skip to main content
14,691,808 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i jst need to convert a datagrid to excel.For that i wrote the following code,

        Response.AddHeader("content-disposition", "attachment;filename=DailyReport.xls");
        Response.Charset = "";
        Response.ContentType = "~/SDailyReport.xls";
        System.IO.StringWriter stringWrite = new System.IO.StringWriter();
        System.Web.UI.HtmlTextWriter htmlWrite =
        new HtmlTextWriter(stringWrite);

        DataGrid g1 = new DataGrid();
        List<griddisplay> obj1 = new List<griddisplay>();
        obj1 = bl.Getgrid();
        g1.DataSource = obj1;
        g1.RenderControl (htmlWrite);

i done this code in a system and got the result.i tried the same in another system where ms office is not installed and its not showing any result.SO

whether its essential to have ms office installed in the system to export to excel?
Updated 3-Apr-12 21:32pm

1 solution

Look at this link. It seems to be useful:[^]

I hope it helps,

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900