R library(openxlsx) Error: Workbook has no worksheets

Viewed 5449

I am curious whether any of you experienced a similar error while reading an xlsx document in R:

library(openxlsx) 
data = read.xlsx(file, sheet =1, startRow = 2, colNames = FALSE)

Even when my file has a worksheet an error occurs:

Error in read.xlsx.default(file, sheet =1, startRow = 2, colNames = FALSE) : 
  Workbook has no worksheets

When I manually added another empty worksheet to my xlsx file, all was OK. However, I would like to know how to solve this issue without opening each xlsx file one by one to add another sheet. Do you have any idea how to deal with it? Thank you in advance.

1 Answers
Related