Issue with read.xlsx on enumeration of sheets
Opened this issue · 0 comments
Expected Behavior
I intended to load the first sheet from an excel file which had three sheets, using the read.xlsx command.
Data2 <- read.xlsx("FileName2.xlsx", sheet = 1, colNames = TRUE, cols = DesiredCols2)
Actual Behavior
This produced the following Error Message:
No data found on worksheet.
I found out that I could access the desired sheet either by using the name of the sheet for the argument "sheet", or by setting the argument "sheet" to the index +1.
sheet = 2 returned the first sheet, sheet = 3, second sheet and so on.
In the same R file I used the same command before to load a sheet from another xlsx file which had only one sheet. Here the indexing worked as expected.
Steps to Reproduce the Problem
Data <- read.xlsx("FileName.xlsx", sheet = 1, colNames = TRUE, cols = DesiredCols)
Indexing worked as expected
Data2 <- read.xlsx("FileName2.xlsx", sheet = 1, colNames = TRUE, cols = DesiredCols2)
Indexing didnt behave as expected
Unfortunately I cant provide an example file.
sessionInfo()
- Version of openxlsx: 4.2.3
- Version of R: 4.0.3