S
Selin Can
Hello,
I want to export datagrid to excel. When I export datagrid to excel,
sometimes data are shown corrupted! (Turkish characters!!)
I use this code :
*****
StringWriter tw = new StringWriter();
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.ContentType = "application/vnd.ms-excel";
// I think , I use wrong encoding!
HttpContext.Current.Response.ContentEncoding =
System.Text.Encoding.GetEncoding("iso-8859-9");
// Remove the charset from the Content-Type header.
HttpContext.Current.Response.Charset = "";
System.Web.UI.Html32TextWriter hw = new System.Web.UI.Html32TextWriter(tw);
dataGrid.EnableViewState = false;
dataGrid.RenderControl(hw);
//Write the HTML back to the browser.
HttpContext.Current.Response.Write(tw.ToString());
//End the response.
HttpContext.Current.Response.End();
******
For same datagrid, sometimes is worked,sometimes not. I cannot find any
logic.
Wrong:
ProductName
Total
number
Lays Klasik
0
0
Lays Baharatly
0
0
Lays Zeyt. Kekik
1
1
Ruffles Original
0
0
Doritos Nacho
0
0
AlaTurca Dom Ha?
1
1
Doritos Taco
1
1
AlaTurca Pey Sus
1
1
Eti Popkek Kakao
7
7
Eti Tutku
16
16
True:
ProductName
Total
M1
M2
M3
M4
M5
Lays Klasik
0
0
0
0
0
0
Lays Baharatlý
24
0
8
8
8
0
Lays Zeyt. Kekik
46
1
16
13
16
0
Ruffles Original
47
0
16
15
16
0
Doritos Nacho
8
0
0
8
0
0
AlaTurca Dom Haþ
16
1
0
15
0
0
Doritos Taco
9
1
0
8
0
0
AlaTurca Pey Sus
9
1
0
8
0
0
Eti Popkek Kakao
85
7
16
14
32
16
Eti Tutku
80
16
24
8
24
8
Any suggestion!
Selin CAN
I want to export datagrid to excel. When I export datagrid to excel,
sometimes data are shown corrupted! (Turkish characters!!)
I use this code :
*****
StringWriter tw = new StringWriter();
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.ContentType = "application/vnd.ms-excel";
// I think , I use wrong encoding!
HttpContext.Current.Response.ContentEncoding =
System.Text.Encoding.GetEncoding("iso-8859-9");
// Remove the charset from the Content-Type header.
HttpContext.Current.Response.Charset = "";
System.Web.UI.Html32TextWriter hw = new System.Web.UI.Html32TextWriter(tw);
dataGrid.EnableViewState = false;
dataGrid.RenderControl(hw);
//Write the HTML back to the browser.
HttpContext.Current.Response.Write(tw.ToString());
//End the response.
HttpContext.Current.Response.End();
******
For same datagrid, sometimes is worked,sometimes not. I cannot find any
logic.
Wrong:
ProductName
Total
number
Lays Klasik
0
0
Lays Baharatly
0
0
Lays Zeyt. Kekik
1
1
Ruffles Original
0
0
Doritos Nacho
0
0
AlaTurca Dom Ha?
1
1
Doritos Taco
1
1
AlaTurca Pey Sus
1
1
Eti Popkek Kakao
7
7
Eti Tutku
16
16
True:
ProductName
Total
M1
M2
M3
M4
M5
Lays Klasik
0
0
0
0
0
0
Lays Baharatlý
24
0
8
8
8
0
Lays Zeyt. Kekik
46
1
16
13
16
0
Ruffles Original
47
0
16
15
16
0
Doritos Nacho
8
0
0
8
0
0
AlaTurca Dom Haþ
16
1
0
15
0
0
Doritos Taco
9
1
0
8
0
0
AlaTurca Pey Sus
9
1
0
8
0
0
Eti Popkek Kakao
85
7
16
14
32
16
Eti Tutku
80
16
24
8
24
8
Any suggestion!
Selin CAN