简体   繁体   English

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

[英]Export value from Excel worksheet to Access record

I have an excel spreadsheet that contains the primarky-key/id value for a record in a table in an access database. 我有一个Excel电子表格,其中包含访问数据库中表中记录的primarky-key / id值。

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. 如果可能的话,任何帮助将不胜感激。

Many thanks 非常感谢

Noel 诺埃尔

You can use ADO with Excel and Access. 您可以将ADO与Excel和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. 您可以打开Access记录集并更新或添加字段(列)并一一记录,或者可以使用带有IN关键字或内部连接字符串的SQL语句。

Very roughly: 非常粗略:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM