searchAndReplace

searchAndReplace

PREMIUM TRIAL / ADVANCED

Searches and replaces shared strings and cell values in an Excel document.

Description
public searchAndReplace (string $source, string $target, array $data, string $scope [, array $options])

This method allows the substitution of plain strings and cell values in a XLSX document.

Parameters

source

The path to the source Excel document.

target

The path to the Excel document resulting after the text replacement.

data

The data to be replaced. Plain strings or an array with the following keys: row (row number), col (column number to replace, 1 as first position) and value (value to add).

scope

sharedStrings (text strings) or sheet (cell values).

options

The possible keys and values are:

Key Type Description
sheetName string Sheet name to replace the value when using sheet as scope. All if null.
sheetNumber int Sheet number to replace the value when using sheet as scope. All if null.
Code samples

Example #1

Example #2