Excel 2016 年通过 ODBC 连接到 PostgreSQL 数据库

Connect to a PostgreSQL database through ODBC on Excel 2016

我在使用 ODBC 从 Excel 2016 连接到 PostgreSQL 数据库时遇到问题。

我试过this answer, without success, and this solution from MS,没有更好的结果...

有人成功过吗?我看到了 that Excel 2016 had some troubles with ODBC drivers,但那是一年前的事了,所以我想知道现在情况是否会好一些?

感谢您的帮助。

我猜这是 32/64 位的东西。这是我们在 Excel/Access.

内设置人员使用 PostgreSQL 时遇到的最大问题

底线:如果您的 Excel 实例是 32 位的(通常是这种情况),那么您需要使用 32 位的 ODBC 驱动程序。最新的 Pg ODBC 驱动程序都捆绑在同一个程序集中,所以诀窍是进入 32 位 ODBC 并以这种方式设置驱动程序。

从那里开始,一切都应该是直截了当的:

  • 数据选项卡
  • 来自其他数据源
  • 微软查询
  • Select刚刚设置的数据源

以此类推

我正在开发 Windows 10、64 位版本,但结果我的 Office 软件包是 32 位的。一旦我在这里手动安装了 32 位 postgresql 驱动程序:https://www.postgresql.org/ftp/odbc/versions/msi/, i was then able to correctly enter the Driver along the lines of these guidelines: https://www.connectionstrings.com/postgresql/

最终连接字符串如下所示: Driver={PostgreSQL ANSI};Server=name.text.ap-southeast-2.rds.amazonaws.com;Port=5432;Database=myDBname;

我之前曾将此作为评论,但另一位评论者建议我将此作为答案:在 excel 2016 年 windows,不要浪费时间数据>获取数据>来自数据库。而是使用数据>获取数据>来自其他来源>来自 ODBC。要设置 ODBC: 单击“开始”菜单。 Select 控制面板。 Select 管理工具并双击数据源 (ODBC) 图标。单击系统 DSN 选项卡。这是我从中提取 ODBC set-up 文本的更详细的 article。除了更容易设置之外,"From ODBC" 随 Office Business 或 Office Home 提供,而 "From Database" 仅随 Office Pro 提供。

1.Excel 2016, x86

2.You 需要 x86 odbc-driver https://www.postgresql.org/ftp/odbc/versions/msi/

我用了psqlodbc_13_02_0000-x86.zip

3.Create数据源

-Control Panel
-Administration
-Open the 32 bit ODBC Administrator
-User DSN
-Add new User DSN (MyPostgreDsn), check connection

4.Connect Excel 到 Postgre

-Data 
-From other sources 
-OleDb wizard 
-Other/Advanced
-Microsoft OLE DB Provider for ODBC drivers 
-Connection - use connection string - Build 
-Machine Data Source 
-Choose created data source (MyPostgreDsn) 
-Ok 
-Test Connection 
-Ok 
-Choose table…