| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 723 人关注过本帖
标题:datagrid导出成excel表出现乱码
只看楼主 加入收藏
luyulin
Rank: 1
等 级:新手上路
帖 子:66
专家分:0
注 册:2004-12-18
收藏
 问题点数:0 回复次数:1 
datagrid导出成excel表出现乱码

datagrid导出成excel表出现乱码
代码如下:
Private Sub export_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles export.Click
Response.ContentType = "application/vnd.ms-excel"
Response.Charset = "GB2312"
Me.EnableViewState = False
Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312")
Dim myCItrad As System.Globalization.CultureInfo = New System.Globalization.CultureInfo("ZH-CN", True)
Dim sw As New System.IO.StringWriter(myCItrad)
Dim hw As New System.Web.UI.HtmlTextWriter(sw)
Dim nCur As Integer = DataGrid1.CurrentPageIndex
Dim nSize As Integer = DataGrid1.PageSize
DataGrid1.AllowPaging = False

binddata3()
DataGrid1.RenderControl(hw)
DataGrid1.AllowPaging = True
DataGrid1.CurrentPageIndex = nCur
DataGrid1.PageSize = nSize
binddata3()
Response.Write(sw.ToString())
Response.End()
End Sub

搜索更多相关主题的帖子: excel datagrid 乱码 
2006-03-27 20:39
luyulin
Rank: 1
等 级:新手上路
帖 子:66
专家分:0
注 册:2004-12-18
收藏
得分:0 
以下是引用luyulin在2006-3-27 20:39:00的发言:

datagrid导出成excel表出现乱码
代码如下:
Private Sub export_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles export.Click
        Response.ContentType = "application/vnd.ms-excel"
        Response.Charset = "GB2312"
        Me.EnableViewState = False
        Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312")
        Dim myCItrad As System.Globalization.CultureInfo = New System.Globalization.CultureInfo("ZH-CN", True)
        Dim sw As New System.IO.StringWriter(myCItrad)
        Dim hw As New System.Web.UI.HtmlTextWriter(sw)
        Dim nCur As Integer = DataGrid1.CurrentPageIndex
        Dim nSize As Integer = DataGrid1.PageSize
        DataGrid1.AllowPaging = False

        binddata3()
        DataGrid1.RenderControl(hw)
        DataGrid1.AllowPaging = True
        DataGrid1.CurrentPageIndex = nCur
        DataGrid1.PageSize = nSize
        binddata3()
        Response.Write(sw.ToString())
        Response.End()
    End Sub

2006-03-31 15:44
快速回复:datagrid导出成excel表出现乱码
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.034331 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved