求助:datagrid导出的excel文件出现乱码,vb.net,webform下.
问题是:datagrid导出的excel在打开时候出现乱码。如何处理??谢谢。
原代码如下:
Response.ContentType = "application/vnd.ms-excel "
Response.Charset = " "
Me.EnableViewState = False
Dim sw As System.IO.StringWriter = New System.IO.StringWriter
Dim hw As System.Web.UI.HtmlTextWriter = New HtmlTextWriter(sw)
Dim ncur As Int32 = dg_detail.CurrentPageIndex
Dim nsize As Int32 = dg_detail.PageSize
dg_detail.AllowPaging = False
Call Me.binddata()
' int nCur = dgShow.CurrentPageIndex;
'int nSize = dgShow.PageSize;
' dgShow.AllowPaging = false;
'BindData();
Me.dg_detail.Columns(4).Visible = False
Me.dg_detail.Columns(5).Visible = False
Me.dg_detail.RenderControl(hw)
Me.dg_detail.Columns(4).Visible = True
Me.dg_detail.Columns(5).Visible = True
dg_detail.AllowPaging = True
dg_detail.CurrentPageIndex = ncur
dg_detail.PageSize = nsize
Call Me.binddata()
'dgShow.AllowPaging = true;
'dgShow.CurrentPageIndex = nCur;
'dgShow.PageSize = nSize;
'BindData();
'System.IO.StringWriter sw = new System.IO.StringWriter();
' System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(sw);
' dgShow.RenderControl(hw);