2
votes

I am trying to read an Excel file with odbcConnectExcel2007 function from RODBC package. It works fine when the file is not in use. But when it is, I get the error:

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

I have also tried to include readOnly = TRUE in the function specification, but still no luck. Any ideas anyone?

1
"I am trying to..." do something - what does in look like in terms of lines of code? - lukeA
why RODBC, imo there are better alternatives for reading in excel files, including readxl, gdata or XLConnect - mtoto

1 Answers

2
votes

Try using the read_excel() function from the readxl package - it will allow you to read an Excel file into R while the file is in use.