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

Fontwidth #109

Merged
merged 7 commits into from
Mar 29, 2022
Merged

Fontwidth #109

merged 7 commits into from
Mar 29, 2022

Conversation

JanMarvin
Copy link
Owner

@JanMarvin JanMarvin commented Mar 29, 2022

[R/setColWidths] basic support for setColWidths widths = "auto"

sheet <- "mtcars"
wb <- wb_workbook()
wb <- wb_add_worksheet(wb, sheet)
# mtcars <- data.frame(test = 12345678)
writeData(wb, sheet, mtcars, rowNames = T)

cols <- 1:12
setColWidths(wb, sheet, cols = cols, widths = "auto")

wb_open(wb)

I like that my included C# code works (maybe even as expected, haven't done anything in C# in a long long time), but there are still a few bugs on the R side of things.

  • a. even if the formula is calculated perfectly, the cells in Excel may still be too small or too wide; I am not sure what causes this. (To get around this, we calculate the value as given, but then round to an even number.)
  • b. Character columns are another story. Especially with long characters, formatting, and line breaks, don't expect us to ever support this, because even Excel is bad at determining the optimal size for character cells. Numbers, however, are smaller than text without monospace fonts, so cells are consistently calculated too wide for text columns.
  • c. "auto" only works with the base font at the moment. If a particular style specifies a different font, only the base font is used for the calculation.
  • d. I calculated the list only for the integer sequence 2 - 25. If higher/lower values or fractions in between are used, we could fall back to a default value.

@JanMarvin
Copy link
Owner Author

Codecov Report

Merging #109 (9d25e85) into main (f866ae2) will decrease coverage by 0.05%.
The diff coverage is 0.00%.

@@            Coverage Diff             @@
##             main     #109      +/-   ##
==========================================
- Coverage   57.29%   57.24%   -0.06%     
==========================================
  Files          40       40              
  Lines        7304     7311       +7     
==========================================
  Hits         4185     4185              
- Misses       3119     3126       +7     
Impacted Files Coverage Δ
R/class-workbook-wrappers.R 31.22% <0.00%> (-0.38%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f866ae2...9d25e85. Read the comment docs.

@JanMarvin JanMarvin merged commit 728df2f into main Mar 29, 2022
@JanMarvin JanMarvin deleted the fontwidth branch March 29, 2022 16:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant