VB6.0中把ACCESS中的数据库资料转到EXCEL中,在EXCEL表头中显示的是ACCESS数据库中的英文字段,要怎样显示所需要中文标题呀。
'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
--------------------编程问答--------------------
select id as 工号--------------------编程问答-------------------- http://download.csdn.net/source/1483928 --------------------编程问答-------------------- 不要用Excel.Application对象,连接ACCESS,直接用SQL语句处理... --------------------编程问答-------------------- 请直接在源程序上帮我改正 --------------------编程问答-------------------- 能修改rs_data 的获取方式么?? --------------------编程问答-------------------- 要是能的话把sql语句展示出来 --------------------编程问答-------------------- 用AS 子句来更改结果集列名或为导出列指定名称就可以了 --------------------编程问答-------------------- 对不过是SQL语句AS进行
补充:VB , 数据库(包含打印,安装,报表)