Exporting to Excel with Chinese Characters

Discussion in 'ASP .Net Datagrid Control' started by tarunbajaj@gmail.com, Oct 15, 2005.

  1. Guest

    Hello all,
    I am using the code below the DataGrid to Excel but my Chinese
    characters are not converted most of the time.
    The data otherwise display the chars correctly in chinese.
    I am not able to find a concrete solution for this.
    This code works alright with English
    Thanks for help
    private void ShowReport( DataTable pResult )
    {
    dgResult.DataSource = pResult;
    dgResult.DataBind();


    //create the filename
    string strName = REPORT_FILENAME;
    strName = strName +
    Convert.ToString(DateTime.Now.ToShortDateString());
    strName = strName.Replace('/', '_');
    strName = strName + ".xls";
    //strName = strName + ".csv";

    Response.Clear();
    Response.Buffer= true;
    Response.ContentType = "application/vnd.ms-excel";
    Response.AddHeader("Content-Disposition", "attachment;filename=" +
    strName);
    Response.Charset = "UTF-8";
    this.EnableViewState = true;
    System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
    System.Web.UI.HtmlTextWriter oHtmlTextWriter = new
    System.Web.UI.HtmlTextWriter(oStringWriter);

    dgResult.RenderControl(oHtmlTextWriter);
    Response.Write(oStringWriter.ToString());
    Response.End();

    } //end of ShowReport()
     
    , Oct 15, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Goran Djuranovic
    Replies:
    0
    Views:
    359
    Goran Djuranovic
    Dec 10, 2004
  2. Replies:
    7
    Views:
    6,626
    Joerg Jooss
    Feb 25, 2005
  3. Replies:
    2
    Views:
    354
  4. omegaman
    Replies:
    1
    Views:
    566
    omegaman
    Sep 21, 2004
  5. zxo102
    Replies:
    1
    Views:
    568
    John Machin
    Aug 15, 2005
Loading...

Share This Page