Skip to content

Commit 0d726cb

Browse files
committed
cleanup. table style check now allows custom table styles
1 parent 3478520 commit 0d726cb

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

R/write.R

+9-8
Original file line numberDiff line numberDiff line change
@@ -883,15 +883,16 @@ write_data_table <- function(
883883
}
884884

885885
## If 0 rows append a blank row
886-
validNames <- c("none", paste0("TableStyleLight", seq_len(21)), paste0("TableStyleMedium", seq_len(28)), paste0("TableStyleDark", seq_len(11)))
886+
cstm_tableStyles <- rbindlist(xml_attr(wb$styles_mgr$styles$tableStyles, "tableStyles", "tableStyle"))$name
887+
validNames <- c("none", paste0("TableStyleLight", seq_len(21)), paste0("TableStyleMedium", seq_len(28)), paste0("TableStyleDark", seq_len(11)), cstm_tableStyles)
887888
if (!tolower(tableStyle) %in% tolower(validNames)) {
888-
warning("Invalid table style.")
889-
} else {
890-
tableStyle <- grep(paste0("^", tableStyle, "$"), validNames, ignore.case = TRUE, value = TRUE)
891-
tableStyle <- tableStyle[!is.na(tableStyle)]
892-
if (length(tableStyle) == 0) {
893-
warning("Unknown table style.")
894-
}
889+
stop("Invalid table style.")
890+
}
891+
892+
tableStyle <- grep(paste0("^", tableStyle, "$"), validNames, ignore.case = TRUE, value = TRUE)
893+
tableStyle <- tableStyle[!is.na(tableStyle)]
894+
if (length(tableStyle) == 0) {
895+
stop("Unknown table style.")
895896
}
896897

897898
## If zero rows, append an empty row (prevent XML from corrupting)

0 commit comments

Comments
 (0)