【发布时间】:2015-01-03 14:03:32
【问题描述】:
我试图使用 write.xlsx 编写一个包含 523370 行和 3 列的数据帧
write.xlsx(x = dataframe, file = "dataframe.xlsx",
+ sheetName = "dataframe1", row.names = FALSE)
但我收到此错误:
Error in .jnew("org/apache/poi/xssf/usermodel/XSSFWorkbook") :
Java Exception <no description because toString() failed>.jnew("org/apache/poi/xssf/usermodel/XSSFWorkbook")<S4 object of class "jobjRef">
我检查了这些问题:
-
How to clear memory used by rJava? :
xlcFreeMemory()然后尝试写入文件,但经过相当长的时间后,我得到了同样的错误 -
R writing excel file with XLSX package taking a long time and error :
write.xlsx2()给了我同样的错误,运行这个后:options(java.parameters = "-Xmx1024m")并重新启动系统
但是那改错误改成:
Error in .jcheck(silent = FALSE) :Java Exception <no description because toString() failed>.jcall(row[[ir]], "Lorg/apache/poi/ss/usermodel/Cell;", "createCell", as.integer(colIndex[ic] - 1))<S4 object of class "jobjRef">
【问题讨论】:
-
很遗憾没有答案,但另一种方法是尝试从包
openxlsxgithub.com/awalker89/openxlsx 中的 write.xlsx -
感谢您的评论@ChristofKluß。它没有找到 write.xlsx 作为命令。但是我遇到的问题是数据框的体积,我必须拆分数据框。并使用
WriteXLS将它们保存在不同的工作表中。 -
我注意到当你同时使用 dplyr 和 xlsx 包时会发生这种情况,那时可能会有冲突。