Link to home
Start Free TrialLog in
Avatar of AhmedHindy
AhmedHindyFlag for Egypt

asked on

export grid view to excel encoding problem

i am exporting grid view into excel
but i am having problem in encoding
arabic characters are not displayed properly  
 
public void ExportGridViewToExcel(HttpResponse Response, GridView GridView_Excel)
    {
        string attachment = "attachment; filename=Transactions.xls";

        Response.ClearContent();

        HttpContext.Current.Response.ContentEncoding = Encoding.GetEncoding("utf-8");
        HttpContext.Current.Response.Charset = "utf-8";

        Response.AddHeader("content-disposition", attachment);

        Response.ContentType = "application/ms-excel";

        StringWriter sw = new StringWriter();

        HtmlTextWriter htw = new HtmlTextWriter(sw);

        GridView_Excel.RenderControl(htw);

        Response.Write(sw.ToString());

        Response.End();

    }

Open in new window


any help ??? !!!!!!
public void ExportGridViewToExcel(HttpResponse Response, GridView GridView_Excel)
    {
        string attachment = "attachment; filename=Transactions.xls";

        Response.ClearContent();

        HttpContext.Current.Response.ContentEncoding = Encoding.GetEncoding("utf-8");
        HttpContext.Current.Response.Charset = "utf-8";

        Response.AddHeader("content-disposition", attachment);

        Response.ContentType = "application/ms-excel";

        StringWriter sw = new StringWriter();

        HtmlTextWriter htw = new HtmlTextWriter(sw);

        GridView_Excel.RenderControl(htw);

        Response.Write(sw.ToString());

        Response.End();

    }

Open in new window

Avatar of jagssidurala
jagssidurala
Flag of India image

ASKER CERTIFIED SOLUTION
Avatar of Easwaran Paramasivam
Easwaran Paramasivam
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of AhmedHindy

ASKER

it worked
add this and it worked
:)

Response.Charset = "";