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

[wb_load] add path to object on. closes #741 #742

Merged
merged 2 commits into from
Aug 17, 2023
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
1 change: 1 addition & 0 deletions R/wb_load.R
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ wb_load <- function(
xmlFiles <- xmlFiles[ordr]

wb <- wb_workbook()
wb$path <- file

grep_xml <- function(pattern, perl = TRUE, value = TRUE, ...) {
# targets xmlFiles; has presents
Expand Down
14 changes: 14 additions & 0 deletions tests/testthat/test-read_from_created_wb.R
Original file line number Diff line number Diff line change
Expand Up @@ -173,3 +173,17 @@ test_that("reading with pre defined types works", {
expect_equal(got, dat, ignore_attr = TRUE)

})

test_that("wb_load contains path", {

tmp <- temp_xlsx()
wb_workbook()$add_worksheet()$add_worksheet()$save(tmp)
wb_load(tmp)$remove_worksheet()$save()

wb <- wb_load(tmp)

exp <- c(`Sheet 1` = "Sheet 1")
got <- wb$get_sheet_names()
expect_equal(exp, got)

})
2 changes: 1 addition & 1 deletion tests/testthat/test-read_sources.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ test_that("wb_load from different sources", {
wb_file <- wb_load(xlsxFile)

# Loading from URL vs local not equal
expect_equal_workbooks(wb_url, wb_file, ignore_fields = "datetimeCreated")
expect_equal_workbooks(wb_url, wb_file, ignore_fields = c("datetimeCreated", "path"))
})


Expand Down
Loading