xlsx icon indicating copy to clipboard operation
xlsx copied to clipboard

Apache POI fails on some xlsx files

Open mhlinder opened this issue 6 years ago • 1 comments

I have confirmed this problem is not due to this R package.

However, this R package is the best R-based API to Apache POI that I have found, so I wanted to document the behavior.

I suspect it may also be possible to side-step the issue with a non-NULL value for password, thereby using XSSFWorkbook instead, but this is beyond my Java skills...any suggestions are appreciated!


On some machine-generated .xlsx files—but not all of them—loadWorkbook fails:

> fn1 %>% basename
[1] "December2017.xlsx"
> fn2 %>% basename
[1] "01 January2018.xlsx"
> fn3 %>% basename
[1] "02 February2018.xlsx"
> w1 <- loadWorkbook(fn1)
> w3 <- loadWorkbook(fn3)
> w2 <- loadWorkbook(fn2)
Error in .jcall("RJavaTools", "Ljava/lang/Object;", "invokeMethod", cl,  : 
  java.lang.NullPointerException

Specifically, this can be traced to the call to WorkbookFactor.create:

inputStream <- .jnew("java/io/File", path.expand(fn2))
wbFactory <- .jnew("org/apache/poi/ss/usermodel/WorkbookFactory")
> wb <- wbFactory$create(inputStream)
Error in .jcall("RJavaTools", "Ljava/lang/Object;", "invokeMethod", cl,  : 
  java.lang.NullPointerException

mhlinder avatar Feb 05 '19 00:02 mhlinder

Thanks for the report! Do you have an example file that causes the crash that you would be able to share?

colearendt avatar Feb 06 '19 13:02 colearendt