Thanks to visit codestin.com
Credit goes to github.com

Skip to content
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 NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

export(list_fods_sheets)
export(list_ods_sheets)
export(ods_sheets)
export(read_fods)
export(read_ods)
export(write_ods)
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ length(list_ods_sheets("starwars.ods"))
* Added `as_tibble` and `.name_repair` as arguments. If `as_tibble` is true, outputs as a tibble using `tibble::as_tibble()` passing on `.name_repair` (default being `"unique"`). **By default** `as_tibble` is set to TRUE.
* Removed `check_names` argument. All name repairs are now dealt with using `vctrs::vec_as_names()`. This will **significantly change** the default names given to outputs. (Names in the style of `check_names = TRUE` can be obtained by setting `.name_repair = minimal`, although this is not advised)

## Defer the removal of `ods_sheets` to v3

There are many reverse dependencies using `ods_sheets`.

# readODS 1.9.0

Expand Down
11 changes: 10 additions & 1 deletion R/list_ods_sheets.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#' @param path Path to the (f)ods file
#' @param include_external_data A boolean value to show or hide sheets containing archived linked data (default false)
#' @return For `list_(f)ods_sheets`, a character vector of sheet names; for `get_num_sheets_in_(f)ods`, the total number of sheets
#' @details `ods_sheets` will be removed in the next major version. It was kept for backward compatibility. Please use `list_ods_sheet`
#' instead. The default "include_external_data" for `ods_sheets` is TRUE to maintain compatibility with version 1 of readODS.
#' @author Peter Brohan <peter.brohan+cran@@gmail.com>, Chung-hong Chan <chainsawtiney@@gmail.com>, Gerrit-Jan Schutten <phonixor@@gmail.com>
#' @examples
#' \dontrun{
Expand All @@ -19,9 +21,16 @@ list_ods_sheets <- function(path, include_external_data = FALSE) {
return(get_sheet_names_(file = path, include_external_data = include_external_data))
}


#' @rdname list_ods_sheets
#' @export
list_fods_sheets <- function(path, include_external_data = FALSE) {
return(get_flat_sheet_names_(file = path, include_external_data = include_external_data))
}


#' @rdname list_ods_sheets
#' @export
ods_sheets <- function(path) {
warning("ods_sheets will be deprecated in the next major version. Use `list_ods_sheets` instead.")
list_ods_sheets(path, include_external_data = TRUE)
}
5 changes: 2 additions & 3 deletions R/writeODS.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
file.copy(file.path(temp_ods_dir, basename(path)), path, overwrite = overwrite)
}

.write_as_utf8 <- function(text, con){
utf8 <- enc2utf8(text)
writeLines(utf8, con = con, sep = "", useBytes = TRUE)
.write_as_utf8 <- function(text, con) {
writeLines(enc2utf8(text), con = con, sep = "", useBytes = TRUE)
}

.find_sheet_node_by_sheet <- function(spreadsheet_node, sheet) {
Expand Down
7 changes: 7 additions & 0 deletions man/list_ods_sheets.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions tests/testthat/test_list_sheets.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,11 @@ test_that("fods works as well", {
expect_equal(list_fods_sheets("../testdata/flat.fods"),
c("Sheet1", "Sheet2"))
})

test_that("keep `ods_sheets` #131", {
expect_warning(y <- ods_sheets("../testdata/linkeddata.ods"))
expect_equal(y,
c("Own",
"contains_linked_data",
"'file:///D:/Users/peter.brohan/Documents/R/readODScpp/tests/testdata/linksource.xlsx'#Sheet1"))
})