diff --git a/R/class-workbook.R b/R/class-workbook.R index a8ea9f428..2022cd656 100644 --- a/R/class-workbook.R +++ b/R/class-workbook.R @@ -2397,9 +2397,11 @@ wbWorkbook <- R6::R6Class( tab_attr <- xml_attr(xml, "table")[[1]] tab_attr[["ref"]] <- dims - tab_autofilter <- xml_node(xml, "table", "autoFilter") - tab_autofilter <- xml_attr_mod(tab_autofilter, xml_attributes = c(ref = dims)) - + tab_autofilter <- NULL + if ("autofilter" %in% tab_nams) { + tab_autofilter <- xml_node(xml, "table", "autoFilter") + tab_autofilter <- xml_attr_mod(tab_autofilter, xml_attributes = c(ref = dims)) + } tab_tabColumns <- xml_node(xml, "table", "tableColumns") tab_cols <- names(self$to_df(sheet = sheet, dims = dims)) diff --git a/tests/testthat/test-tables.R b/tests/testthat/test-tables.R index 0a3e360af..5089422c5 100644 --- a/tests/testthat/test-tables.R +++ b/tests/testthat/test-tables.R @@ -196,4 +196,11 @@ test_that("updating table works", { got <- wb_to_df(wb, named_region = "Table2") expect_equal(exp, got, ignore_attr = TRUE) + wb <- wb_workbook()$add_worksheet()$add_data_table(x = mtcars, with_filter = FALSE) + wb$update_table(tabname = "Table1", dims = "A1:J4") + + exp <- "A1:J4" + got <- wb$tables$tab_ref + expect_equal(exp, got) + })