Skip to content

Commit d914366

Browse files
authored
Fix469 (#470)
* temp * Fix #469
1 parent 8a2ff18 commit d914366

File tree

8 files changed

+58
-11
lines changed

8 files changed

+58
-11
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,6 @@ Suggests:
7878
License: GPL-2
7979
VignetteBuilder: knitr
8080
Encoding: UTF-8
81-
RoxygenNote: 7.3.1
81+
RoxygenNote: 7.3.2
8282
Roxygen: list(markdown = TRUE)
8383
Config/Needs/website: gesistsa/tsatemplate

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ S3method(.import,rio_syd)
7070
S3method(.import,rio_tsv)
7171
S3method(.import,rio_txt)
7272
S3method(.import,rio_xls)
73+
S3method(.import,rio_xlsm)
7374
S3method(.import,rio_xlsx)
7475
S3method(.import,rio_xml)
7576
S3method(.import,rio_xpt)

R/import_list.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ import_list <- function(file, setclass = getOption("rio.import.class", "data.fra
9595
return(.import.rio_rdata(file = file, .return_everything = TRUE, ...))
9696
}
9797
archive_format <- find_compress(file)
98-
if (!format %in% c("html", "xlsx", "xls", "ods", "fods") && !archive_format$compress %in% c("zip", "tar", "tar.gz", "tar.bz2")) {
98+
if (!format %in% c("html", "xlsx", "xls", "xlsm", "ods", "fods") && !archive_format$compress %in% c("zip", "tar", "tar.gz", "tar.bz2")) {
9999
which <- 1
100100
whichnames <- NULL
101101
}
@@ -112,7 +112,7 @@ import_list <- function(file, setclass = getOption("rio.import.class", "data.fra
112112
)
113113
names(which) <- whichnames
114114
}
115-
if (format %in% c("xls", "xlsx", "ods", "fods")) {
115+
if (format %in% c("xls", "xlsx", "xlsm","ods", "fods")) {
116116
## .check_pkg_availability("readxl")
117117
sheet_func <- readxl::excel_sheets
118118
if (format %in% c("ods", "fods")) {

R/import_methods.R

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,9 @@ import_delim <- function(file, which = 1, sep = "auto", header = "auto", strings
287287
.remap_tidy_convention(readxl::read_xlsx, file = file, which = which, header = header, ...)
288288
}
289289

290+
#' @export
291+
.import.rio_xlsm <- .import.rio_xlsx
292+
290293
#' @export
291294
.import.rio_fortran <- function(file, which = 1, style, ...) {
292295
if (missing(style)) {

R/sysdata.rda

47 Bytes
Binary file not shown.

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ The full list of supported formats is below:
149149
| Epiinfo | epiinfo / rec | foreign | | Default | |
150150
| Excel | excel / xlsx | readxl | writexl | Default | |
151151
| Excel (Legacy) | xls | readxl | | Default | |
152+
| Excel (Read only) | xlsm / xltx / xltm | readxl | | Default | |
152153
| Fixed-width format data | fwf | readr | utils | Default | |
153154
| Fortran data | fortran | utils | | Default | No recognized extension |
154155
| Google Sheets | googlesheets | data.table | | Default | As comma-separated data |

data-raw/single.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,33 @@
233233
"export_function": "writexl::write_xlsx",
234234
"note": ""
235235
},
236+
{
237+
"input": "xlsm",
238+
"format": "xlsm",
239+
"type": "import",
240+
"format_name": "Excel (Read only)",
241+
"import_function": "readxl::read_xlsx",
242+
"export_function": "",
243+
"note": ""
244+
},
245+
{
246+
"input": "xltx",
247+
"format": "xlsm",
248+
"type": "import",
249+
"format_name": "Excel (Read only)",
250+
"import_function": "readxl::read_xlsx",
251+
"export_function": "",
252+
"note": ""
253+
},
254+
{
255+
"input": "xltm",
256+
"format": "xlsm",
257+
"type": "import",
258+
"format_name": "Excel (Read only)",
259+
"import_function": "readxl::read_xlsx",
260+
"export_function": "",
261+
"note": ""
262+
},
236263
{
237264
"input": "fst",
238265
"format": "fst",

tests/testthat/test_format_xls.R

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,28 @@ test_that("Import from Excel (.xls)", {
5151
})
5252

5353
test_that("Import from Excel (.xlsm)", {
54-
expect_true(is.data.frame(import("../testdata/example.xlsm", sheet = 1, format = "xlsx")))
55-
expect_true(is.data.frame(import("../testdata/example.xlsm", which = 1, format = "xlsx")))
56-
expect_equal(
57-
import_list("../testdata/example.xlsm", format = "xlsx"),
58-
list(
59-
Sheet1 = data.frame(A = 1),
60-
Sheet2 = data.frame(B = 2)
54+
expect_true(is.data.frame(import("../testdata/example.xlsm", sheet = 1, format = "xlsx")))
55+
expect_true(is.data.frame(import("../testdata/example.xlsm", which = 1, format = "xlsx")))
56+
expect_true(is.data.frame(import("../testdata/example.xlsm")))
57+
58+
expect_equal(
59+
import_list("../testdata/example.xlsm", format = "xlsx"),
60+
list(
61+
Sheet1 = data.frame(A = 1),
62+
Sheet2 = data.frame(B = 2)
63+
)
64+
)
65+
expect_equal(
66+
import_list("../testdata/example.xlsm"),
67+
list(
68+
Sheet1 = data.frame(A = 1),
69+
Sheet2 = data.frame(B = 2)
70+
)
6171
)
62-
)
72+
})
73+
74+
test_that("Exporting to xlsm is not supported #469", {
75+
withr::with_tempfile("iris_file", fileext = ".xlsm", code = {
76+
expect_error(export(iris, iris_file), "Format not supported")
77+
})
6378
})

0 commit comments

Comments
 (0)