'VB6.0中把ACCESS中的数据库资料转到EXCEL中,在EXCEL表头中显示的是ACCESS数据库中的英文字段,要怎样显示中文呀。
Public Function exportoexcel(rs_data As ADODB.Recordset)
'  *********************************************************
'  *   名称:exportoexcel
'  *   功能:导出数据到excel
'  *   用法:exportoexcel(sql查询字符串)
'  *********************************************************
'  Dim rs_data     As New ADODB.Recordset
  Dim irowcount     As Integer
  Dim icolcount     As Integer
            
          Dim xlapp     As New Excel.Application
          Dim xlbook     As Excel.Workbook
          Dim xlsheet     As Excel.Worksheet
          Dim xlquery     As Excel.QueryTable
            
     
         With rs_data
                  If .RecordCount < 1 Then
                          MsgBox ("没有记录!")
                          Exit Function
                  End If
                '  记录总数
                  irowcount = .RecordCount
                '  字段总数
                  icolcount = .Fields.Count
          End With
            
          Set xlapp = CreateObject("excel.application")
          Set xlbook = Nothing
          Set xlsheet = Nothing
          Set xlbook = xlapp.Workbooks().Add
          Set xlsheet = xlbook.Worksheets("sheet1")
          xlapp.Visible = True
            
       '   添加查询语句,导入excel数据
         Set xlquery = xlsheet.QueryTables.Add(rs_data, xlsheet.Range("a1"))
             
          With xlquery
                  .FieldNames = True
                  .RowNumbers = False
                  .FillAdjacentFormulas = False
                  .PreserveFormatting = True
                  .RefreshOnFileOpen = False
                  .BackgroundQuery = True
                  .RefreshStyle = xlInsertDeleteCells
                  .SavePassword = True
                  .SaveData = True
                  .AdjustColumnWidth = True
                  .RefreshPeriod = 0
                  .PreserveColumnInfo = True
          End With
            
         xlquery.FieldNames = True      ' 显示字段名
         xlquery.Refresh
         
          xlapp.Application.Visible = True
          Set xlapp = Nothing           '"交还控制给excel
          Set xlbook = Nothing
          Set xlsheet = Nothing
    
  End Function