Патриарх
Зарегистрирован: 09 October 2003
Сообщения: 1744
Примеры кода: 48
|
RE: export datagrid to Excel проблема с charset |
31 December 2007 16:26 |
|
|
|
|
пытаюсь экспортировать датагрид в эксель
почему-то при сохранении что-то происходит с кодировкой, и при сохранении файла получаются закорючки вместо имен вот в таком духе..
lname
I“I‘I›I‘I?IYI IYI?I›IYI?
I?I‘I?I¤I—I?
I?I IYI?I?I”I‘I?
I›I•IsIsI‘I?
I‘I?I I?IYI IYI?I›IYI?
I?I I™I?I?I I™IsI—I?
MANAJ
I?I™I‘I”I—I?I‘
I?I™IsIYI›I‘IYI?
I I‘I I‘IsI©I?I?I¤I‘I?I¤I™I?IYI?
вот код экспорта
HttpContext.Current.Response.Clear()
HttpContext.Current.Response.ContentType = "application/vnd.ms-excel"
HttpContext.Current.Response.AddHeader("content-disposition", "attachment;filename=" & saveAsFile & ".xls")
' Remove the charset from the Content-Type header.
HttpContext.Current.Response.Charset = ""
'System.Text.Encoding.ASCII.ToString() '"Windows - 1253"
'HttpContext.Current.Response.WriteFile("style.txt")
' Turn off the view state.
grid.EnableViewState = False
Dim tw As New System.IO.StringWriter
Dim hw As New System.Web.UI.HtmlTextWriter(tw)
' Get the HTML for the control.
grid.HeaderStyle.ForeColor = Color.White
grid.HeaderStyle.BackColor = Color.Gray
grid.ItemStyle.ForeColor = Color.Black
grid.BorderColor = Color.White
ClearControls(grid)
grid.RenderControl(hw)
' Write the HTML back to the browser.
HttpContext.Current.Response.Write(tw.ToString())
' End the response.
HttpContext.Current.Response.End()
http://www.aspnetmania.com/Code/Code.aspx?ID=36
http://www.aspnetmania.com/Forums/ForumMessage/42448.html
 Работай так, чтобы Великий Учитель Dimon aka одобрил, и AL похвалил!
|
|