HttpContext.Current.Response.Clear();
HttpContext.Current.Response.Buffer = true;
HttpContext.Current.Response.Charset = "iso-8859-9";
HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF8;
//open file
StreamWriter wr = new StreamWriter(@"D:\\book.xls");
for (int i = 0; i < dt.Columns.Count; i++)
{
wr.Write(string.Format(new CultureInfo("tr-TR"),dt.Columns[i].ToString().ToUpper() + "\t"));
}
wr.WriteLine();
//write rows to excel file
for (int i = 0; i < (dt.Rows.Count); i++)
{
for (int j = 0; j < dt.Columns.Count; j++)
{
if (dt.Rows[i][j] != null)
{
wr.Write(string.Format(new CultureInfo("tr-TR"), Convert.ToString(dt.Rows[i][j]) + "\t"));
}
else
{
wr.Write("\t");
}
}
//go to next line
wr.WriteLine();
}
//close file
wr.Close();
My problem is EĞİTİM
is automatically changed to EÄİTİM
when exporting to Excel.