1

I have read this article that exports datatable to excel file. It worked great.

Export DataTable to Excel File

and the code is below:

dt = city.GetAllCity();//your datatable 
string attachment = "attachment; filename=city.xls"; 
Response.ClearContent(); 
Response.AddHeader("content-disposition", attachment); 
Response.ContentType = "application/vnd.ms-excel"; 
string tab = ""; 
foreach (DataColumn dc in dt.Columns) 
{ 
    Response.Write(tab + dc.ColumnName); 
    tab = "\t"; 
} 
Response.Write("\n"); 
int i; 
foreach (DataRow dr in dt.Rows) 
{ 
    tab = ""; 
    for (i = 0; i < dt.Columns.Count; i++) 
    { 
        Response.Write(tab + dr[i].ToString()); 
        tab = "\t"; 
    } 
    Response.Write("\n"); 
} 
Response.End(); 

But when I use this codes, the korean characters are all broken. Can anyone help me with this problem?

Community
  • 1
  • 1
Joshua Son
  • 1,839
  • 6
  • 31
  • 51

1 Answers1

2

I use windows-1254 character set for Turkish. I guess KS_X_1001 will work for you. For more sets : http://en.wikipedia.org/wiki/Character_encoding

Response.ContentEncoding = System.Text.Encoding.GetEncoding("windows-1254");
Response.Charset = "windows-1254";
Nalaka526
  • 11,278
  • 21
  • 82
  • 116
Erben
  • 21
  • 2