xlsxFindReplace: Find and Replace Text in an Excel File

View source: R/utilsFiles.R

xlsxFindReplaceR Documentation

Find and Replace Text in an Excel File

Description

This function reads an Excel file and replaces specified text (oldname) with a new text (newname) across all sheets. You can specify whether to replace only whole words and whether to perform case-sensitive or case-insensitive replacements.

Usage

xlsxFindReplace(
  xlsxName,
  pattern,
  replacement,
  word = FALSE,
  ignore.case = TRUE,
  listonly = FALSE
)

Arguments

xlsxName

The name (including path) of the Excel (.xlsx) file to modify.

pattern

The text to search for in the Excel file.

replacement

The text that will replace oldname.

word

Logical, if TRUE only whole words will be replaced.

ignore.case

Logical, if TRUE the function ignores case.

listonly

Logical. If TRUE, the function only lists the files that would be modified without actually modifying them. Defaults to FALSE.

Value

Returns list: name of file assessed = number of changes; the function modifies the Excel file in-place and prints a message indicating the modified file.

Examples

## Not run: 
xlsxFindReplace("example.xlsx", "oldText", "newText")

## End(Not run)

Epiconcept-Paris/STRAP-epiuf documentation built on Aug. 5, 2024, 3:41 a.m.