openxlsx
openxlsx copied to clipboard
use "auto" for setRowheights
Hello,
It seems like it was already done at one point, but is not present in the current version of openxlsx. https://github.com/awalker89/openxlsx/pull/382
This feature would be incredibly useful. Not sure what happened to it.
I'm using openxlsx 4.2.5
Thank you for all your great work!
Hi @David-Rattray , it looks like it was never merged. Would you like to carry the pull request over and try it out?
Hi @JanMarvin, yeah I would love to give it a whirl. However, I'm very unfamiliar with github. I'll see if I can figure out how to do that.
Thanks, let me know if there's anything I can help you with on the openxlsx side of things. For GitHub there are countless guides how to do things, there will be one answering your questions :)
@JanMarvin I've been following the contribution guidelines for openxlsx:
usethis::create_from_github("ycphs/openxlsx", fork = TRUE)
,
after running devtools::check()
there are zero errors, 1 warning, and 1 note. Not sure if that is fine to continue with or something to straight out first.
After that I'm going to try and figure out how to bring @Davidbreuer 's code from the pull request into a new pull request here.
I'd say just start playing with the code :) Fixing things like warnings is a chore for after the implementation. No need to fix stuff only to realize that it doesn't work as expected.
@JanMarvin Managed to straighten out some of the problems, however test-encoding, and test-styles still produce errors when running the check. I've tried using it to produce a report, however I encounter an error (with Rcpp I think)
Error in write_worksheet_xml_2(prior = prior, post = post, sheet_data = ws$sheet_data, : Not compatible with STRSXP: [type=NULL].
See if I can figure it out, but if you have any ideas or suggestions that would be appreciated!
Hi @David-Rattray , if you could open a PR I can have a look. Simply push your changes to your fork of openxlsx
and click open pull request when the github popup appears. From this error alone, I'm not able to tell you where to look at. Either prior
or post
are not STRSXP
(character
), but NULL
or something inside that function threw this error.
@JanMarvin Yeah I'll do that in a moment, I think its the row_heights_ = NULL part of the write_worksheet_xml_2. Line 141 of the Rcpp Exports file
I'll have a look, but maybe on the weekend. Thanks for pushing this forward :)
@JanMarvin hope I'm not bugging you. Just put together a minimal reproducible example for me at least.
library(openxlsx)
wb <- createWorkbook(creator = "David-Rattray")
addWorksheet(wb, sheetName = "Cover Page")
setColWidths(wb, sheet = "Cover Page", cols = 1:2, widths = 13)
setRowHeights(wb, sheet = "Cover Page", rows = 14, heights = 9.80)
saveWorkbook(wb, "C:/git projects/test/test.xlsx", overwrite = TRUE)
Error in write_worksheet_xml_2(prior = prior, post = post, sheet_data = ws$sheet_data, :
Not compatible with STRSXP: [type=NULL].
> sessionInfo()
R version 4.0.5 (2021-03-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19044)
Matrix products: default
locale:
[1] LC_COLLATE=English_Canada.1252 LC_CTYPE=English_Canada.1252 LC_MONETARY=English_Canada.1252
[4] LC_NUMERIC=C LC_TIME=English_Canada.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] openxlsx_4.2.5.9000
loaded via a namespace (and not attached):
[1] compiler_4.0.5 tools_4.0.5 Rcpp_1.0.8.3 stringi_1.7.6 zip_2.2.0
>
I'll try and poke around a bit myself too
No your not bugging me, it's just that I'm currently focusing on another project and switching back and forth is not always helpful. I'll get to it and thanks for the example.
That's the output of the setRowHeights()
example

Hello, I've tried using this in the latest version (4.2.5.2) and it's still not working. I'm assuming no one has had time to update it yet? No pressure - I just want to make sure I'm not just using it wrong. Thanks
I would also love to see this feature implemented. Please consider merging if the code is functional.
This issue is stale because it has been open 365 days with no activity. Remove stale label or comment or this will be closed in 7 days.
This issue was closed because it has been stalled for 7 days with no activity.