Exporting to Excel with Chinese Characters

T

tarunbajaj

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()
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top