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

[read] reading cell region with blank rows works #1273

Merged
merged 5 commits into from
Feb 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: openxlsx2
Title: Read, Write and Edit 'xlsx' Files
Version: 1.13
Version: 1.13.0.9000
Language: en-US
Authors@R: c(
person("Jordan Mark", "Barbone", email = "jmbarbone@gmail.com", role = "aut", comment = c(ORCID = "0000-0001-9788-3628")),
Expand Down
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# openxlsx2 (development version)


***************************************************************************

# openxlsx2 1.13

## New features
Expand Down
1 change: 1 addition & 0 deletions R/read.R
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ wb_to_df <- function(
sst <- attr(wb$sharedStrings, "text")

rnams <- row_attr$r
rnams <- rnams[rnams %in% unique(cc$row_r)] # avoid blank row interference

numfmt_date <- numfmt_is_date(wb$styles_mgr$styles$numFmts)
xlsx_date_style <- style_is_date(wb$styles_mgr$styles$cellXfs, numfmt_date)
Expand Down
23 changes: 23 additions & 0 deletions tests/testthat/test-read_from_created_wb.R
Original file line number Diff line number Diff line change
Expand Up @@ -278,3 +278,26 @@ test_that("shared formulas are handled", {
expect_equal(exp, got)

})

test_that("reading with blank rows works (#1272)", {

wb <- wb_workbook()$add_worksheet()$
add_data(dims = "A1", x = 1)$
add_data(dims = "A4:E4", x = rep(1, 5))

rr <- wb$worksheets[[1]]$sheet_data$row_attr

rr <- create_char_dataframe(names(rr), n = 2)
rr$r <- as.character(2:3)

wb$worksheets[[1]]$sheet_data$row_attr <- rbind(
wb$worksheets[[1]]$sheet_data$row_attr,
rr,
stringAsFactors = FALSE
)

got <- wb$to_df(dims = "A2:E3", col_names = FALSE)

expect_equal(c(2L, 5L), dim(got))

})
Loading