openxlsx icon indicating copy to clipboard operation
openxlsx copied to clipboard

use "auto" for setRowheights

Open David-Rattray opened this issue 2 years ago • 14 comments

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!

David-Rattray avatar Jul 18 '22 22:07 David-Rattray

Hi @David-Rattray , it looks like it was never merged. Would you like to carry the pull request over and try it out?

JanMarvin avatar Jul 19 '22 09:07 JanMarvin

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.

David-Rattray avatar Jul 19 '22 15:07 David-Rattray

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 avatar Jul 19 '22 16:07 JanMarvin

@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.

David-Rattray avatar Jul 20 '22 18:07 David-Rattray

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 avatar Jul 20 '22 19:07 JanMarvin

@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!

David-Rattray avatar Jul 26 '22 16:07 David-Rattray

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 avatar Jul 26 '22 17:07 JanMarvin

@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

David-Rattray avatar Jul 26 '22 18:07 David-Rattray

I'll have a look, but maybe on the weekend. Thanks for pushing this forward :)

JanMarvin avatar Jul 26 '22 18:07 JanMarvin

@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

David-Rattray avatar Jul 27 '22 15:07 David-Rattray

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.

JanMarvin avatar Jul 27 '22 16:07 JanMarvin

That's the output of the setRowHeights() example

Screenshot 2022-07-30 at 12 06 20

JanMarvin avatar Jul 30 '22 10:07 JanMarvin

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

Tom-K-UKRI avatar Mar 28 '23 10:03 Tom-K-UKRI

I would also love to see this feature implemented. Please consider merging if the code is functional.

lewkrr avatar May 23 '23 20:05 lewkrr

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.

github-actions[bot] avatar May 25 '24 02:05 github-actions[bot]

This issue was closed because it has been stalled for 7 days with no activity.

github-actions[bot] avatar Jun 01 '24 02:06 github-actions[bot]