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

Writing large formated data frames is slow #420

Closed
JanMarvin opened this issue Nov 18, 2022 · 2 comments · Fixed by #423
Closed

Writing large formated data frames is slow #420

JanMarvin opened this issue Nov 18, 2022 · 2 comments · Fixed by #423

Comments

@JanMarvin
Copy link
Owner

Similar to #356. Writing a large data frame with dates is slow. This is caused by the for loop in add_numfmt().

library(openxlsx2)

beg <- "1900-1-1"
end <- "2000-11-18"

dat <- seq(
  from = as.POSIXct(beg, tz="UTC"),
  to   = as.POSIXct(end, tz="UTC"),
  by   = "day"
)

out <- data.frame(
  date = dat,
  chr  = as.character(dat),
  num  = seq_along(dat)-1
)

wb <- wb_workbook() %>% 
  wb_add_worksheet() %>% wb_add_data(x = out) %>% 
  wb_open()
@JanMarvin
Copy link
Owner Author

It's definitely unwanted and unexpected behavior. Yet atm I have no desire to touch this part of the code again. If this nags you, feel free to submit a PR.

@JanMarvin
Copy link
Owner Author

Likely it would speed things up, if we collect all unique previous styles, instead of asking every cell for its style. Maybe call table on the styles, modify the possible styles and replace their old id with the new id. This way we'd only have to loop through a couple of cell styles instead of every single cell.

@JanMarvin JanMarvin linked a pull request Nov 19, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant