Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

export grid view to excel encoding problem

Posted on 2011-09-18
4
Medium Priority
?
3,397 Views
Last Modified: 2012-05-12
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

0
Comment
Question by:AhmedHindy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 16

Accepted Solution

by:
Easwaran Paramasivam earned 1500 total points
ID: 36559128

Add Response.Write("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />") in your code.

Refer: http://forums.asp.net/t/1467766.aspx

0
 
LVL 4

Author Closing Comment

by:AhmedHindy
ID: 36954698
it worked
0
 
LVL 4

Author Comment

by:AhmedHindy
ID: 37023762
add this and it worked
:)

Response.Charset = "";
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

661 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