读取打开的 Excel 文件

Reading an open Excel file

我正在尝试从 RODBC 包中读取带有 odbcConnectExcel2007 函数的 Excel 文件。当文件未被使用时,它工作正常。但是当它出现时,我得到了错误:

Warning messages: 1: In odbcDriverConnect(con, tabQuote = c("[", "]"), ...) : [RODBC] ERROR: state HY000, code -1028, message [Microsoft][ODBC Excel Driver] Cannot open database '(unknown)'. It may not be a database that your application recognizes, or the file may be corrupt. 2: In odbcDriverConnect(con, tabQuote = c("[", "]"), ...) : ODBC connection failed

我也试过在函数规范中包含 readOnly = TRUE,但仍然没有成功。有什么想法吗?

尝试使用 readxl 包中的 read_excel() 函数 - 它允许您在文件正在使用时将 Excel 文件读入 R。