用VB写的,将数据库中的数据导出到Excel中,但导出后汉字部分出现了乱码。不知是怎么回事,请各位帮帮忙!代码如下:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load  Dim adapter As New SqlDataAdapter
  Dim MyConnection As New SqlConnection
  Dim Myselectcommand As New System.Data.SqlClient.SqlCommand
  MyConnection.ConnectionString = "data source=work6;Initial catalog=CRMData-test;User ID=sa;Password=123"
  Myselectcommand.CommandText = "select * from log"
  Myselectcommand.CommandType = CommandType.Text
  Myselectcommand.Connection = MyConnection  adapter.SelectCommand = Myselectcommand
  Dim dtable As DataTable
  dtable = New DataTable
  adapter.Fill(dtable)
  Response.ContentType = "application/ms-Excel"  Response.AddHeader("Content-Disposition", "inline;filename=log_backup.xls")
End SubPrivate Function ConvertDtToTDF(ByVal dt As DataTable) As String
  Dim dr As DataRow, ary() As Object, i As Integer
  Dim iCol As Integer
  For iCol = 0 To dt.Columns.Count - 1
    Response.Write(dt.Columns(iCol).ToString & vbTab)
  Next
  Response.Write(vbCrLf)
  For Each dr In dt.Rows
    ary = dr.ItemArray
    For i = 0 To UBound(ary)
      Response.Write(ary(i).ToString & vbTab)
    Next
    Response.Write(vbCrLf)
  Next
End Function