Click here to Skip to main content
15,910,661 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,

C#
Response.Clear();
        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.DataBind();
        g1.RenderControl (htmlWrite);
        Response.Write(stringWrite.ToString());
        Response.End();


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?
Posted
Updated 3-Apr-12 20:32pm
v3

1 solution

Hi,
Look at this link. It seems to be useful:
http://forums.asp.net/t/1081527.aspx[^]

I hope it helps,
Cheers
 
Share this answer
 

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