将Excel文件读入Access数据库的最佳方式 [英] Best way to read an Excel file into an Access database

查看:285
本文介绍了将Excel文件读入Access数据库的最佳方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从Access 2007应用程序中读取(只读)Excel文件的最佳方式是什么。我只想循环移动行并将数据放入Access表。

What's the "best" way to read (just read) an Excel file from within an Access 2007 application. I only want to loop trough the rows and put the data into an Access table.

我不想手动导入(获取外部数据对话框),而是VBA。用户获取具有浏览按钮的窗体,然后指向具有定义的内容/格式的Excel文件。之后,VBA代码读取数据并将其放入Access数据库。

I don't want a manually import (Get External Data dialog) but by VBA. The user gets a Form with a Browse button and then points to a Excel file with a defined content/format. After that the VBA code reads the data and puts it into the Access database.

推荐答案

您可以尝试DoCmd.TransferSpreadsheet方法。

You could try the DoCmd.TransferSpreadsheet method.

DoCmd.TransferSpreadsheet acImport, , "from_excel","C:\Access\demo.xls", True

将电子表格数据导入名为from_excel的表格,并假定电子表格的第一行包含字段名称。请参阅访问TransferSpreadsheet或联机的帮助 here ,更多细节。

That imports spreadsheet data into a table named from_excel, and assumes the first row of the spreadsheet contains field names. See Access help for TransferSpreadsheet or online here, for more details.

这篇关于将Excel文件读入Access数据库的最佳方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆