I have an excel spreadsheet with several sheets. The format is as below:
Date A B C D E F Referenc
You can use library XLConnect
to read .xls files. Function readWorksheet()
lets you set columns and rows you need to import.
library(XLConnect)
wb<-loadWorkbook("wb.xls")
data <- readWorksheet(wb, sheet = "Sheet1",startCol=1,endCol=7)
Another option is to use is to use Excel named range
with RODBC
.
channel<-odbcConnectExcel(paste(Repository,excelFile, sep = "/"))
ConsoTab<-sqlFetch(channel,NamesRangeAF)
odbcClose(channel)
Here NamesRangeAF
is your Excel named Range.
With the readxl
package using read_xlsx
you can specify the range. Use read_xls or read_excel depending on file type.
library(readxl)
df <- read_xlsx(path = "filename.xlsx", sheet = "sheetname", range = cell_cols("A:G"))