IllegalArgumentException (Java): Sheet index (-1) is out of range (0..2), NULL (crazy excel sheet reading)

R is getting crazy with reading my excel sheets. I am using the package XLConnect to load a workbook. suppress content and write new table resulting from R (because I want to save the styling in the workbook). For now, it worked fine. I added some try catch things to my code for every file reading. and know I get a weird thing where when I read file1, it tells my I have the worksheets PR B and PR C instead of what I actually have which are sheets PR A and PR C. XLConnect and readxl both tell me this! and the number of lines they read is not the same as in the actual file (for the first sheet more, for the second less). WHAT IS GOING ON??? I have PR B NOWHERE!!!!!!!

Hi @sarabclui can you post the file (or an altered version of it).

Since XLConnect requires a Java distribution on the system, most R developers will not be familiar with it (there are a lot of alternatives for reading excel files not having such a strong dependency f.e. openxlsx, openxlsx2, readxl).

I will give it a try with XLConnect if you post it.

1 Like

Agree - strongly recommend openxlsx or openxlsx2

I can't change the package for the moment.

I can't test anything without a sample.