Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wb_load fails #261

Closed
sigbertklinke opened this issue Jul 5, 2022 · 3 comments
Closed

wb_load fails #261

sigbertklinke opened this issue Jul 5, 2022 · 3 comments
Labels
bug 🐛 Something isn't working

Comments

@sigbertklinke
Copy link

Hi,

the following MWE fails

library("magrittr")
library("openxlsx2")
who <- c("Emma", "Charlotte", "Amelia", "Ava", "Sophia")
for (i in who) {
#  browser()
  file  <- paste0(substr(i, 1, 1), ".xlsx")
  message(file)
  wb    <- if (!file.exists(file)) wb_load("Vorlage0.xlsx") else wb_load(file)
  wb$clone_worksheet("Vorlage", i)
  wb$add_data(x = i, startCol = 2, startRow = 1)
  wb$save(file)
}

with a error message when calling wb_load(file)

E.xlsx
C.xlsx
A.xlsx
A.xlsx
Fehler in names(z) <- as.character(nam) : 
  Attribut 'names' [3] muss dieselbe Länge haben wie der Vektor [1]

Vorlage0.xlsx

@JanMarvin
Copy link
Owner

Hi @sigbertklinke , confirmed the bug. It's caused by the headerfooter logic. Initially we read the file "Vorlage0.xlsx", when saving it and trying to read it again, we fail:

nam
[1] "L" "C" "R"
z
[1] "&amp;&quot;Times New Roman,Standard&quot;&amp;12&amp;A"

@JanMarvin JanMarvin added the bug 🐛 Something isn't working label Jul 5, 2022
@JanMarvin
Copy link
Owner

Pushed a fix to #262 Previously exported files are indeed broken, thanks for the report! Your file has only a center entry in header and footer (visible in print preview in LibreOffice). Our export for this type of files was broken.

@JanMarvin
Copy link
Owner

While we could offer an option to skip the imports of header and footer to read our own broken files, we are still in development, therefore I decided that I don't care to much.

JanMarvin pushed a commit that referenced this issue Jul 8, 2022
[R/save] fix writing headerFooter. fixes #261
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants