ADODC+ACCESS+DATAGRID+EXECL
我已做到,把符合条件的记录反映在DATAGRID上,但是如何把DATAGRID上的数据输出到EXECL上,并打开。
想法1:就是上面所说
想法2:把adodc的记录集存在临时表中,并用execl打开它不知如何做法,请求高手相助,感激!
我已做到,把符合条件的记录反映在DATAGRID上,但是如何把DATAGRID上的数据输出到EXECL上,并打开。
想法1:就是上面所说
想法2:把adodc的记录集存在临时表中,并用execl打开它不知如何做法,请求高手相助,感激!
Dim xlBook As Object
Dim xlSheet As Object
Dim xlQuery As Object
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks().Add
Set xlSheet = xlBook.Worksheets("sheet1")
Set xlQuery = xlSheet.QueryTables.Add(rs, xlSheet.Range("A1"))
xlApp.Visible = False
With xlQuery
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = False
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = 1
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.FieldNames = True
.Refresh
End With
xlApp.displayalerts = False
xlBook.SaveAs filename '要保存的文件
xlBook.Close
xlApp.Quit
Set xlApp = Nothing
Set xlBook = Nothing
Set xlSheet = Nothing
Set xlQuery = Nothing