XDF 파일 rxImport를 사용 하 여 Excel ODBC 인터페이스를 통해 Excel 스프레드시트를 가져올 수 있습니다. Excel ODBC 드라이버가 설치 되 고 구성 창 것이 "C:/Data/ODBCTest.xlsx" 통합 문서에서 "Sheet1" 워크시트를 가져오기 위한 코드 예제를 제공.
#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)