这个SQL对你有帮助:Select * INTO mydbf In [DBase5;Database=c:\my document\].销售表.dbfSelect * INTO mytext In [Text;Database=c:\my document\].报告.txtSelect * INTO mysheet In [Excel 8.0;Database=c:\my document\].Sheet.xsl
以下可以保存在Excel文件中, '引用excel9.0 Dim tempxlApp As New Excel.Application Dim tempxlWorkbook As New Excel.Workbook Dim tempxlSheet As New Excel.WorksheetDim tempRange As String Dim strRangeValue As String '打开自己作好的报表模板templet.xlt Set tempxlWorkbook = tempxlApp.Workbooks.Open(App.Path & "\templet.xlt") tempxlApp.Visible = True tempxlApp.DisplayAlerts = False tempxlWorkbook.SaveAs "report.xls" Set tempxlSheet = tempxlWorkbook.Worksheets("sheet1") tempxlSheet.Select'单个单元格写入数据 tempxlSheet.Range("A1").Value = "test" '一次性写入tempRs数据记录集中的数据 tempxlSheet.Range("A1").CopyFromRecordset tempRS '保存 tempxlApp.save '释放对象 Set tempxlSheet = Nothing Set tempxlWorkbook = Nothing '关闭excel tempxlApp.Quit Set tempxlApp = Nothing
'引用excel9.0
Dim tempxlApp As New Excel.Application
Dim tempxlWorkbook As New Excel.Workbook
Dim tempxlSheet As New Excel.WorksheetDim tempRange As String
Dim strRangeValue As String
'打开自己作好的报表模板templet.xlt
Set tempxlWorkbook = tempxlApp.Workbooks.Open(App.Path & "\templet.xlt")
tempxlApp.Visible = True
tempxlApp.DisplayAlerts = False
tempxlWorkbook.SaveAs "report.xls"
Set tempxlSheet = tempxlWorkbook.Worksheets("sheet1")
tempxlSheet.Select'单个单元格写入数据
tempxlSheet.Range("A1").Value = "test"
'一次性写入tempRs数据记录集中的数据
tempxlSheet.Range("A1").CopyFromRecordset tempRS
'保存
tempxlApp.save '释放对象
Set tempxlSheet = Nothing
Set tempxlWorkbook = Nothing
'关闭excel
tempxlApp.Quit
Set tempxlApp = Nothing
AccessApp.DoCmd.TransferDatabase
具体的用法,请参考access帮助文件
dao的例子:
dbs.Execute "Select * INTO [DBase5;Database=c:\my document\].[销售表.dbf] FROM [表1];"