0

I'm trying to export my workbook object with openxlsx2 package, but I got an error message as following.

dat2 = wb_load("data.xlsx" ,data_only = F, calc_chain = T)
num =  c(600000,12340)
dat2 = dat2 %>% wb_add_data(sheet = 1, x = num, dims = "E17")
wb_save(dat2, file = 'QQQ.xlsx', overwrite = F)

Error in `$<-.data.frame`(`*tmp*`, tmpDirPartName, value = "C:\\Users\\nergul18\\AppData\\Local\\Temp\\RtmpCKmbVx\\workbookTemp_b0cc4801ed2/xl/worksheets/") : 
  replacement has 1 row, data has 0

What does this error mean and How do I handle this one?

5
  • Your code works fine for me. R version 4.2.3, openxlsx2_1.0 Commented Oct 25, 2023 at 8:11
  • What is "data.xlsx"? I just tested with a spreadsheet of my own, and it also worked without error. Linux, R-4.3.1, openxlsx2-1.1 Commented Oct 25, 2023 at 12:08
  • As for that error, it's based on stackoverflow.com/q/29814912/3358272. Because of the reference to tmpDirPartName (and github.com/JanMarvin/openxlsx2/blob/…), it seems likely that this is a bug in the package. I suggest you open a new bug report, where it will be even more important to make this reproducible, either by providing data.xlsx that generates the error, or creating an xlsx file programmatically that triggers the error. Good luck! Commented Oct 25, 2023 at 12:12
  • As author of the package I second r2evans suggestion. If there is a problem, please make it reproduce able and open an issue. And please do not use the calc_chain option. Setting this has the tendency to brick your file! Commented Oct 25, 2023 at 19:59
  • I've opened an issue here. It might be that OPs input file is somehow incomplete. Lacking either workbook.xml.rels or Content_Types. I wasn't aware that either case is possible. Commented Oct 25, 2023 at 20:29

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.