将值从Excel工作表导出到Access记录

问题描述:

我有一个Excel电子表格,其中包含访问数据库中表中记录的primarky-key/id值.

I have an excel spreadsheet that contains the primarky-key/id value for a record in a table in an access database.

我想将特定数据从电子表格中的某些单元格导出到表中相应记录的某些字段中.

I would like to export specific data from certain cells in the spreadsheet to certain fields in the corresponding record in the table.

是否有可能,任何帮助将不胜感激.

Is this possible, any help would be greatly appreciated.

非常感谢

Noel

您可以将ADO与Excel和Access一起使用.您可以打开Access记录集并更新或添加字段(列)并一一记录,或者可以使用带有IN关键字或内部连接字符串的SQL语句.

You can use ADO with Excel and Access. You can either open an Access recordset and update or add fields (columns) and records one by one, or you can use an SQL statement with IN key word or an internal connection string.

非常粗略:

strCon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\docs\mydb.mdb"

Set cn = CreateObject("ADODB.Connection")

cn.Open strCon

strSQL="SELECT * INTO NewTable  FROM [Sheet1$] IN '' " _
  & "[Excel 8.0;HDR=YES;IMEX=2;DATABASE=C:\Docs\WB.xls]"

cn.Execute strSQL