首页 > 解决方案 > 如何在未安装 Office 的情况下在 ArcMap 中打开 .xls 文件?

问题描述

我正在尝试在 ArcMap 10.6.1 的目录窗口中打开和复制 xls 文档。每次我尝试展开表格时,都会收到以下错误消息:

“连接数据库失败。一般功能失败。外部表没有预期的格式。” (从德语翻译)

我尝试安装(然后更新)“2007 Office System Driver:Data Connectivity Components”“Microsoft Access Database Engine 2010 Redistributable”,但这没有帮助。

我在没有安装 Office 的情况下在 Windows Server 2012 R2 上运行 ArcGIS 10.6.1。有趣的是,在另一台机器上,运行 ArcGIS 10.5.1,操作系统相同,没有 Office,它工作正常!

标签: excelarcgisxlsarcmap

解决方案


试试这个,它可以帮助您使用 arcpy 窗口读取和使用 .xls 中的数据:

import arcpy
import xlrd
inputExcel = xlrd.open_workbook("C:\Users\username\In_excel.xls")
sheetNames = inputExcel.sheet_names()
excelSheet = inputExcel.sheet_by_name(sheetNames[0])
for x in range (0, excelSheet.nrows):
    for y in range (0 excelSheet.ncols):
        cellValue = excelSheet.cell_value(x, y)
        print (cellValue)

推荐阅读