如何将access的数据导出存成excel文件

suncsdn 2003-08-19 04:22:39
请各位大虾帮忙
...全文
109 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
sbwgi 2003-08-22
  • 打赏
  • 举报
回复
另外,我以前保存EXCEL是这样写的,语句简单一点:
Private Sub saveToXls(ByVal xlsFileName As String)
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim Export_Str As String

Set xlApp = CreateObject("Excel.Application") 'create Excel application
Hide
Export_Str = "select * into [Excel 8.0;database=" & xlsFileName & ".xls].[sheet1] from product"
conn.Execute Export_Str
frmDataOper.Show
xlApp.Quit
End Sub

这个函数也要在cmdSave_Click()里面调用,而cmdSave_Click()跟上面一样。
sbwgi 2003-08-22
  • 打赏
  • 举报
回复
下面是我的代码:

Private Sub saveToXls(ByVal xlsFileName As String)
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Dim oldPointer As Integer 'used to save the current
Dim rPointer As Integer 'current saving record
Dim xlsPointer As Integer 'used to point out the position
'the current record saving

oldPointer = rs_com.Bookmark 'save current pointer of rs_com
xlsPointer = 2 'the first line of Excel sheet
Set xlApp = CreateObject("Excel.Application") 'create Excel application
Set xlBook = xlApp.Workbooks.Add
Set xlSheet = xlBook.Worksheets(1)
Hide
frmSaveProgress.Show 'show the progress status
rs_com.MoveFirst
Dim i As Integer
While Not rs_com.EOF 'save ecah record to Excel file
For i = 0 To 8 'save each field to Excel cell
xlSheet.Cells(xlsPointer, i + 1) = rs_com.Fields(i)
Next
frmSaveProgress.nextStep (rs_com.Bookmark / rs_com.RecordCount)
rs_com.MoveNext
xlsPointer = xlsPointer + 1
Wend
Unload frmSaveProgress 'end save to Excel file
frmDataOper.Show
xlBook.SaveAs (xlsFileName)
xlBook.Close
xlApp.Quit
End Sub

Private Sub cmdSave_Click()
diaSave.Filter = "Excel文件|*.xls" 'set to save as Excel file
Dim bOk As Boolean
bOk = True
If isInFindMode Then
MsgBox "正在查找中,请先退出查找再进行保存!", vbInformation, "注意"
Exit Sub
End If
Do While bOk
diaSave.ShowSave 'show save dialog
If diaSave.FileName = "" Then
Exit Sub
Else
'do save here
bOk = False
Call saveToXls(diaSave.FileName)
MsgBox "保存结束!", vbInformation, "通知"
End If
Loop
End Sub

上面代码中的frmSaveProgress函数是自己写的。是在保存数据至EXCEL时用来显示保存进度的。你可以去掉。
suncsdn 2003-08-20
  • 打赏
  • 举报
回复
我库里面的字段名称和给用户显示的excel文件的字段名称不一样,比如我库里面的字段是smallclass_name ,excel中的是小类名称,而且库里面的字段只是一部分显示在excel中
suncsdn 2003-08-20
  • 打赏
  • 举报
回复
我要的是用程序怎样实现?请各位帮帮忙!
suncsdn 2003-08-20
  • 打赏
  • 举报
回复
to changechange(改了又改)
http://www.access911.net/index.asp?board=4&mode=3&recordid=74FAB31E14DC
显示:服务器严重错误,请立即与管理员联系
changechange 2003-08-19
  • 打赏
  • 举报
回复
http://www.access911.net/index.asp?board=4&mode=3&recordid=74FAB31E14DC
http://www.access911.net/index.asp?board=4&mode=3&recordid=72FABF1E15DC
http://www.access911.net/index.asp?board=4&mode=3&recordid=74FAB41E1ADC
http://www.access911.net/index.asp?board=4&mode=3&recordid=74FAB01E11DC

方法太多了
wangcd 2003-08-19
  • 打赏
  • 举报
回复
如何程序实现?
以选择所需要的项进行输出
cheny1234 2003-08-19
  • 打赏
  • 举报
回复
access2002:
1.工具栏“用Ms Excel分析”
2.excel用odbc连接access
3.ctrl+c ,ctrl+v
cx3322 2003-08-19
  • 打赏
  • 举报
回复
文件菜单中不是有导出这一项吗,进行选择就行了。有各种文件式的数据表文件,要埋选择

7,712

社区成员

发帖
与我相关
我的任务
社区描述
Microsoft Office Access是由微软发布的关系数据库管理系统。它结合了 MicrosoftJet Database Engine 和 图形用户界面两项特点。
社区管理员
  • Access
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧