You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What steps will reproduce the problem?
wb <- createWorkbook()
sheet <- createSheet(wb)
dfr <- data.frame(x = 1:5)[,FALSE] #Data frame with some rows, no columns.
addDataFrame(dfr, sheet)
## Error in .jcall(cellBlock$ref, "V", setDataMethod, as.integer(j - 1L), :
## java.lang.ArrayIndexOutOfBoundsException: 1
What is the expected output? What do you see instead?
I expected addDataFrame to gracefully decline to add any content to the
worksheet rather than throwing an error.
What version of the product are you using? On what operating system?
xlsx version '0.5.5'.
Please provide any additional information below.
The problem is caused by line 46 (depending upon how you count them):
for (j in 1:ncol(x)) {
When x has zero columns, then 1:ncol(x) is c(1, 0), not an empty vector.
To fix the problem, change the line to:
for(j in seq_along(x)) {
Original issue reported on code.google.com by richiero...@gmail.com on 30 Jan 2014 at 11:32
The text was updated successfully, but these errors were encountered:
A quick search through the source of xlsx reveals that the file write.xlsx.R
contains two more instances of 1:ncol, and five instances of 1:nrow. I haven't
checked to see if these cause problems, but it is safer to replaces them with
calls to seq_len or seq_along.
Original comment by richiero...@gmail.com on 30 Jan 2014 at 11:35
Original issue reported on code.google.com by
richiero...@gmail.com
on 30 Jan 2014 at 11:32The text was updated successfully, but these errors were encountered: