Feuilles de calcul Excel peuvent être importés dans les fichiers XDF à l’aide de la rxImport via l’interface ODBC Excel. Étant donné que le pilote ODBC Excel est installé et configuré sur Windows, un exemple de code pour l’importation d’une feuille de calcul « Sheet1 » du classeur « C:/Data/ODBCTest.xlsx » serait :
#Define ODBC connection string.connectionStr <- "Driver={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};DriverId=790;Dbq=C:/Data/ODBCTest.xlsx;DefaultDir=c:/Data;"
#Define ODBC query into workbook. The worksheet name must be followed by '$' and enclosed in [].
testExcel = "SELECT * FROM [Sheet1$]"
#Define ODBC data source for the import using the query and connection string.
excelDS<- RxOdbcData(sqlQuery = testExcel, connectionString=connectionStr)
#Define input workbook and output xdf file.
excelDS_XDF<- RxXdfData("testFromExcel.xdf")
#Import the workbook into the XDF
rxImport(excelDS, excelDS_XDF, overwrite=TRUE)