How to load an Excel worksheet with rxImport

Excel spreadsheets can be imported into XDF files using rxImport via the Excel ODBC interface. Given that the Excel ODBC driver is installed and configured on Windows, an example of code for importing a worksheet "Sheet1" from workbook "C:/Data/ODBCTest.xlsx" would be:
#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 XDFrxImport(excelDS, excelDS_XDF, overwrite=TRUE)
Note This is a "FAST PUBLISH" article created directly from within the Microsoft support organization. The information contained herein is provided as-is in response to emerging issues. As a result of the speed in making it available, the materials may include typographical errors and may be revised at any time without notice. See Terms of Use for other considerations.

ID článku: 3103845 - Poslední kontrola: 11/01/2015 15:44:00 - Revize: 1.0

Revolution Analytics

  • KB3103845
Váš názor