diff --git a/R/utils.R b/R/utils.R index 619ed682b..653cb1a8e 100644 --- a/R/utils.R +++ b/R/utils.R @@ -53,7 +53,7 @@ temp_xlsx <- function(name = "temp_xlsx", macros = FALSE) { } #' helper function to create temporary directory for testing purpose -#' @param pattern pattern from `base::tempfile()` +#' @inheritParams base::tempfile pattern #' @keywords internal #' @noRd temp_dir <- function(pattern = "file") { @@ -320,11 +320,38 @@ un_list <- function(x) { names(x) <- nams x } - +# `fmt_txt()` ------------------------------------------------------------------ #' format strings independent of the cell style. +#' +#' #' @details #' The result is an xml string. It is possible to paste multiple `fmt_txt()` #' strings together to create a string with differing styles. +#' +#' Using `fmt_txt(charset = 161)` will give the Greek Character Set +#' +#' | charset| "Character Set" | +#' |--------|----------------------| +#' | 0 | "ANSI_CHARSET" | +#' | 1 | "DEFAULT_CHARSET" | +#' | 2 | "SYMBOL_CHARSET" | +#' | 77 | "MAC_CHARSET" | +#' | 128 | "SHIFTJIS_CHARSET" | +#' | 129 | "HANGUL_CHARSET" | +#' | 130 | "JOHAB_CHARSET" | +#' | 134 | "GB2312_CHARSET" | +#' | 136 | "CHINESEBIG5_CHARSET"| +#' | 161 | "GREEK_CHARSET" | +#' | 162 | "TURKISH_CHARSET" | +#' | 163 | "VIETNAMESE_CHARSET" | +#' | 177 | "HEBREW_CHARSET" | +#' | 178 | "ARABIC_CHARSET" | +#' | 186 | "BALTIC_CHARSET" | +#' | 204 | "RUSSIAN_CHARSET" | +#' | 222 | "THAI_CHARSET" | +#' | 238 | "EASTEUROPE_CHARSET" | +#' | 255 | "OEM_CHARSET" | +#' #' @param x a string or part of a string #' @param bold bold #' @param italic italic @@ -336,31 +363,8 @@ un_list <- function(x) { #' @param charset integer value from the table below #' @param outline TRUE or FALSE #' @param vertAlign baseline, superscript, or subscript -#' @details -#' |"Value" | "Character Set" | -#' |--------|----------------------| -#' |"0" | "ANSI_CHARSET" | -#' |"1" | "DEFAULT_CHARSET" | -#' |"2" | "SYMBOL_CHARSET" | -#' |"77" | "MAC_CHARSET" | -#' |"128" | "SHIFTJIS_CHARSET" | -#' |"129" | "HANGUL_CHARSET" | -#' |"130" | "JOHAB_CHARSET" | -#' |"134" | "GB2312_CHARSET" | -#' |"136" | "CHINESEBIG5_CHARSET"| -#' |"161" | "GREEK_CHARSET" | -#' |"162" | "TURKISH_CHARSET" | -#' |"163" | "VIETNAMESE_CHARSET" | -#' |"177" | "HEBREW_CHARSET" | -#' |"178" | "ARABIC_CHARSET" | -#' |"186" | "BALTIC_CHARSET" | -#' |"204" | "RUSSIAN_CHARSET" | -#' |"222" | "THAI_CHARSET" | -#' |"238" | "EASTEUROPE_CHARSET" | -#' |"255" | "OEM_CHARSET" | #' @examples #' fmt_txt("bar", underline = TRUE) -#' @name fmt_txt #' @export fmt_txt <- function( x, @@ -448,13 +452,12 @@ fmt_txt <- function( out } -#' @rdname fmt_txt #' @method + fmt_txt -#' @param x an openxlsx2 fmt_txt string -#' @param y an openxlsx2 fmt_txt string +#' @param x,y an openxlsx2 fmt_txt string #' @details You can join additional objects into fmt_txt() objects using "+". Though be aware that `fmt_txt("sum:") + (2 + 2)` is different to `fmt_txt("sum:") + 2 + 2`. #' @examples #' fmt_txt("foo ", bold = TRUE) + fmt_txt("bar") +#' @rdname fmt_txt #' @export "+.fmt_txt" <- function(x, y) { diff --git a/man/fmt_txt.Rd b/man/fmt_txt.Rd index b8a77f93b..5279b7c90 100644 --- a/man/fmt_txt.Rd +++ b/man/fmt_txt.Rd @@ -28,7 +28,7 @@ fmt_txt( \method{print}{fmt_txt}(x, ...) } \arguments{ -\item{x}{an openxlsx2 fmt_txt string} +\item{x, y}{an openxlsx2 fmt_txt string} \item{bold}{bold} @@ -50,9 +50,9 @@ fmt_txt( \item{vertAlign}{baseline, superscript, or subscript} -\item{y}{an openxlsx2 fmt_txt string} - \item{...}{additional arguments for default print} + +\item{x}{an openxlsx2 fmt_txt string} } \description{ format strings independent of the cell style. @@ -61,27 +61,27 @@ format strings independent of the cell style. The result is an xml string. It is possible to paste multiple \code{fmt_txt()} strings together to create a string with differing styles. -\tabular{ll}{ - "Value" \tab "Character Set" \cr - "0" \tab "ANSI_CHARSET" \cr - "1" \tab "DEFAULT_CHARSET" \cr - "2" \tab "SYMBOL_CHARSET" \cr - "77" \tab "MAC_CHARSET" \cr - "128" \tab "SHIFTJIS_CHARSET" \cr - "129" \tab "HANGUL_CHARSET" \cr - "130" \tab "JOHAB_CHARSET" \cr - "134" \tab "GB2312_CHARSET" \cr - "136" \tab "CHINESEBIG5_CHARSET" \cr - "161" \tab "GREEK_CHARSET" \cr - "162" \tab "TURKISH_CHARSET" \cr - "163" \tab "VIETNAMESE_CHARSET" \cr - "177" \tab "HEBREW_CHARSET" \cr - "178" \tab "ARABIC_CHARSET" \cr - "186" \tab "BALTIC_CHARSET" \cr - "204" \tab "RUSSIAN_CHARSET" \cr - "222" \tab "THAI_CHARSET" \cr - "238" \tab "EASTEUROPE_CHARSET" \cr - "255" \tab "OEM_CHARSET" \cr +Using \code{fmt_txt(charset = 161)} will give the Greek Character Set\tabular{ll}{ + charset \tab "Character Set" \cr + 0 \tab "ANSI_CHARSET" \cr + 1 \tab "DEFAULT_CHARSET" \cr + 2 \tab "SYMBOL_CHARSET" \cr + 77 \tab "MAC_CHARSET" \cr + 128 \tab "SHIFTJIS_CHARSET" \cr + 129 \tab "HANGUL_CHARSET" \cr + 130 \tab "JOHAB_CHARSET" \cr + 134 \tab "GB2312_CHARSET" \cr + 136 \tab "CHINESEBIG5_CHARSET" \cr + 161 \tab "GREEK_CHARSET" \cr + 162 \tab "TURKISH_CHARSET" \cr + 163 \tab "VIETNAMESE_CHARSET" \cr + 177 \tab "HEBREW_CHARSET" \cr + 178 \tab "ARABIC_CHARSET" \cr + 186 \tab "BALTIC_CHARSET" \cr + 204 \tab "RUSSIAN_CHARSET" \cr + 222 \tab "THAI_CHARSET" \cr + 238 \tab "EASTEUROPE_CHARSET" \cr + 255 \tab "OEM_CHARSET" \cr } You can join additional objects into fmt_txt() objects using "+". Though be aware that \code{fmt_txt("sum:") + (2 + 2)} is different to \code{fmt_txt("sum:") + 2 + 2}.