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

Add "centerContinuous" to the halign style property. #510

Closed
egenteman opened this issue Nov 23, 2024 · 2 comments
Closed

Add "centerContinuous" to the halign style property. #510

egenteman opened this issue Nov 23, 2024 · 2 comments

Comments

@egenteman
Copy link

Is your feature request related to a problem? Please describe.
Within excel there is a "Center Across Selection" functionality that is similar to "merge cells" but it keeps the independence of those cells. Right now, openxlsx does not allow "center across selection" but only a function to merge cells.

Describe the solution you'd like
It looks like the createStyle function in wrappers.R has validation over the options that halign will take "left", "right", "center" and "justify". Is adding this feature as simple as adding "centerContinuous" to the validation? Or are there other code changes needed?

@JanMarvin
Copy link
Collaborator

Should be enough, but you have to assign this to every cell.

openxlsx2example (I previously wasn't even aware that this might be possible)

library(openxlsx2)
dim_dat <- wb_dims(x = USPersonalExpenditure, row_names = TRUE, from_row = 2)
dim_hed <- wb_dims(x = USPersonalExpenditure[0,], row_names = TRUE, 
                   above = 1, select = "col_names", from_dims = dim_dat)

wb <- wb_workbook() %>%
  wb_add_worksheet("test") %>%
  wb_add_data(x = USPersonalExpenditure, row_names = TRUE, dims = dim_dat) %>%
  wb_add_data(x = "USPersonalExpenditure", dims = dim_hed) %>%
  # wb_merge_cells(dims = dim_hed) %>%
  wb_add_cell_style(dims = dim_hed, horizontal = "centerContinuous")

if (interactive()) wb$open()
Screenshot 2024-11-23 at 15 02 36

@egenteman
Copy link
Author

Thanks, this is exactly what I needed!

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

No branches or pull requests

2 participants