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

improve fillMergedCells. closes #324 #541

Merged
merged 3 commits into from
Feb 11, 2023
Merged

improve fillMergedCells. closes #324 #541

merged 3 commits into from
Feb 11, 2023

Conversation

JanMarvin
Copy link
Owner

@JanMarvin JanMarvin commented Feb 11, 2023

Now the following is possible

library(openxlsx2)

# Create a workbook where the second row are merged cells from the first row
wb <- wb_workbook()$
  add_worksheet()$
  add_data(x = t(letters[1:4]), colNames = FALSE)$
  add_data(dims = "A3:D6", x = t(matrix(c(1:3, NA_real_), 4, 4)), colNames = FALSE)$
  merge_cells(1, rows = 1:2, cols = 1)$
  merge_cells(1, rows = 1:2, cols = 2)$
  merge_cells(1, rows = 1:2, cols = 3)$
  merge_cells(1, rows = 1:2, cols = 4)

# read the workbook from the second row and fill the merged 
# cells, even though they are outside the selected dimension
wb_to_df(wb, dims = "A2:D4", fillMergedCells = TRUE)
#>   a b c  d
#> 3 1 2 3 NA
#> 4 1 2 3 NA

Presumably with large xlsxFiles it is faster to read from a wbWorkbook instead of reading from a file.

@JanMarvin JanMarvin changed the title Gh issue 324 improve fillMergedCells. closes #324 Feb 11, 2023
@JanMarvin JanMarvin merged commit f57d9e4 into main Feb 11, 2023
@JanMarvin JanMarvin deleted the gh_issue_324 branch February 11, 2023 11:25
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