Skip to contents

Validate an xlsx template file to use in xlsx_cutter()

Usage

validate_xltemplate(
  template_file,
  template_sheet = 1,
  marker_open = "{{",
  marker_close = "}}",
  minimal = FALSE,
  error = FALSE
)

Arguments

template_file

path to the template file to use as a model to parse the xlsx files in data_folder

template_sheet

sheet id of the template file to use as a model to parse the xlsx files in data_folder

marker_open, marker_close

character marker to mark the variables to extract in the template_file

minimal

Logical (default to FALSE) saying whether the template should contain only variables delimited by markers and nothing else, or if extra text can be included (and ignored)

error

Logical (defaults to TRUE) saying whether failed validations should result in an error (TRUE) or a warning (FALSE)

Value

TRUE if the template is valid, FALSE otherwise

Examples

# Valid template
validate_xltemplate(
  system.file("example", "timesheet_template.xlsx", package = "xlcutter")
)
#> [1] TRUE

# Invalid templates
validate_xltemplate(
  system.file("example", "template_duped_vars.xlsx", package = "xlcutter")
)
#> Warning: 2 variables are duplicated in template: var1, var2
#> [1] FALSE

validate_xltemplate(
  system.file("example", "template_fluff.xlsx", package = "xlcutter"),
  minimal = TRUE
)
#> Warning: The provided template is not minimal and includes 1 field not defining any variable
#> [1] FALSE