List xlsx sheetnames with R

user1664455 picture user1664455 · Sep 12, 2012 · Viewed 10.8k times · Source

Is it possible to generate a list of sheetnames within an xlsx file? Or perhaps, can I check if a sheet name exists, and if not, proceed with some designated function?

Answer

Geza picture Geza · Jun 25, 2014

With xlsx library you can get the list of the sheets in an existing workbook with getSheets():

wb <- loadWorkbook(your_xlsx_file)
sheets <- getSheets(wb)