I used openxlsx::read.xlsx
the last time I needed to read many sheets from an XLSX.
#install.packages("openxlsx")
library(openxlsx)
#?openxlsx::read.xlsx
#using file chooser:
filename <- file.choose()
#or hard coded file name:
#filename <- "filename.xlsx"
#get all the sheet names from the workbook
SheetNames<-getSheetNames(filename)
# loop through each sheet in the workbook
for (i in SheetNames){
#Read the i'th sheet
tmp_sheet<-openxlsx::read.xlsx(filename, i)
#if the input file exists, append the new data;; else use the first sheet to initialize the input file
ifelse(exists("input"),
input<-rbind(input, tmp_sheet),
input<-tmp_sheet)
}
Note: This assumes each worksheet has identical column structure and data types. You may need to standardize\normalize the data (ex. tmp_sheet <- as.data.frame(sapply(tmp_sheet,as.character), stringsAsFactors=FALSE)
), or load each sheet into it's own dataframe and pre-process further before merging.