Sign in with Microsoft
Sign in or create an account.
Hello,
Select a different account.
You have multiple accounts
Choose the account you want to sign in with.

Problem

Is there a way to import .xlsx Excel files using rxImport(). rxImport() has ODBC functionality.

Solution

This may be possible if you can setup the proper ODBC connection string and express a correct query but it has not been tested. I will need to investigate whether this is supported. Are you able to verify you can connect to and query the Excel spreadsheet via ODBC outside of R? Can you provide the entire script you are trying to run as well as what version of Excel you are running.

If this will not work with rxImport, an alternative would be the RODBC package which does have more direct Excel/ODBC support. This would bring the Excel spreadsheet into a data frame which could then be written to an XDF file.

Here is a short general example for importing an Excel workbook into an .xdf file:

sConnectionStr <- "Driver={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};DriverId=790;Dbq=C:/Data/ODBCTest.xlsx;DefaultDir=c:/Data;" 
testExcel = "SELECT * FROM [Sheet1$]" 
excelDS<- RxOdbcData(sqlQuery = testExcel, connectionString=sConnectionStr) 
excelDS_XDF<- RxXdfData("testFromExcel.xdf") 
rxImport(excelDS, excelDS_XDF, overwrite=TRUE)

Need more help?

Want more options?

Explore subscription benefits, browse training courses, learn how to secure your device, and more.

Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.

Was this information helpful?

What affected your experience?
By pressing submit, your feedback will be used to improve Microsoft products and services. Your IT admin will be able to collect this data. Privacy Statement.

Thank you for your feedback!

×