IllegalArgumentException when attempting to import XLSX data into R
Solution 1
Please try:
mydata <-read.xlsx2("C:\\Users\\aniruddha\\Downloads\\failingExample.xlsx",1)
Solution 2
For no dependency on Java, you can use readxl.
Library(readxl)
mydata <- read_excel("C:\\Users\\aniruddha\\Downloads\\failingExample.xlsx")
Btw, instead of using \, you can also use a forward slash, like "C:/Users/aniruddha/Downloads/failingExample.xlsx"
Solution 3
In my case read.xlsx2
resulted in no error, but I got an empty data.frame
.
Two other solutions:
- deleting empty rows/columns
- List item directly in excel specifying endRow
Solution 4
This is what helped to solve the same issue:
Exception: IllegalArgumentException: Cell index must be >= 0
Here's the solution that worked out for me: I copied the full data from the input file, where i got this error (above mentioned), I created a new excel file, and pasted the data, and saved it and processed it. It just worked fine.
It might be a formatting issue. I'm not sure, but that's my guess. Because, the same data works fine in a new excel file.
Admin
Updated on June 26, 2022Comments
-
Admin almost 2 years
While importing a xlsx file into R I faced the below error-
mydata <- read.xlsx("C:\\Users\\aniruddha\\Downloads\\failingExample.xlsx",1) Error in .jcall(row[[ir]], "Lorg/apache/poi/ss/usermodel/Cell;", "getCell", : java.lang.IllegalArgumentException: Cell index must be >= 0
Can you please let me know the reason and the possible solution?