searchAndReplace
- addBibliography
- addBookmark
- addBreak
- addChart
- addCitation
- addComment
- addCrossReference
- addDateAndHour
- addEndnote
- addExternalFile
- addFootnote
- addFormElement
- addHeading
- addImage
- addLink
- addList
- addMathEquation
- addMergeField
- addOLE
- addOnlineVideo
- addPageNumber
- addShape
- addSimpleField
- addSource
- addStructuredDocumentTag
- addSVG
- addTab
- addTable
- addTableContents
- addTableFigures
- addText
- addTextBox
- addWordFragment
- addWordML
- embedHTML
- addBackgroundImage
- addFooter
- addFooterSection
- addHeader
- addHeaderSection
- addLineNumbering
- addMacroFromDoc
- addPageBorders
- addProperties
- addSection
- createDocx
- createDocxAndDownload
- createCharacterStyle
- createListStyle
- createParagraphStyle
- createTableStyle
- docxSettings
- embedFont
- importChartStyle
- importHeadersAndFooters
- importListStyle
- importStyles
- importStylesWordDefault
- modifyPageLayout
- parseStyles
- removeFooters
- removeHeaders
- setBackgroundColor
- setDecimalSymbol
- setDefaultFont
- setDocumentDefaultStyles
- setEncodeUTF8
- setLanguage
- setMarkAsFinal
- setRTL
- clearBlocks
- cloneBlock
- deleteBlock
- getTemplateVariables
- getTemplateVariablesType
- modifyInputFields
- modifyMergeFields
- processTemplate
- removeTemplateVariable
- removeTemplateVariableImage
- replaceBlock
- replaceListVariable
- replacePlaceholderImage
- replaceTableVariable
- replaceVariableByExternalFile
- replaceVariableByHtml
- replaceVariableByText
- replaceVariableByWordFragment
- replaceVariableByWordML
- setTemplateSymbol
- setTemplateBlockSymbol
- tickCheckboxes
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
Release notes
- phpdocx 12.5:
- replace parts of string contents.
- phpdocx 8.5:
- new method.