Skip to main content

Replace Text - Excel API

PDF4me Replace Text enables you to find and replace text in Excel documents with literal or regular expression matching. This API service processes all worksheets in the workbook and supports case-sensitive matching, entire cell or partial matching, multiple replacement phrases in a single request, and optional formatting (font, color, size, bold, italic, etc.). The API receives Excel document content through REST API calls, utilizing Base64 encoding for secure transmission. This solution is ideal for data standardization, content updates, and automated text transformation.

Authenticating Your API Request

Include your API key in the request to authenticate with the PDF4me REST API.

Key Features

  • Literal & Regex Support: Replace text using simple matching or regular expressions
  • Case-Sensitive Option: Control case sensitivity for precise or flexible matching
  • Entire Cell Matching: Match partial text or require entire cell match
  • Multiple Replacements: Process multiple search-replace operations in a single request
  • Optional Formatting: Apply font, color, size, and style changes to replaced text
  • All Worksheets: Processes all worksheets in the workbook

REST API Endpoint

  • Method: POST
  • Endpoint: office/ApiV2Excel/ExcelFindAndReplaceTextInExcel

REST API Parameters

Important: Parameters marked with an asterisk (*) are required. All requests use document, docContent, and replaceTextToExcelAction. Operation-specific parameters (phrases, cultureName, etc.) are properties of the action object.

Required Parameters (root level)

ParameterTypeDescriptionExample
document*ObjectDocument reference with Name (Excel file name){ "Name": "data.xlsx" }
docContent*String (Base64)Excel document content encoded in Base64UEsDBBQABgAIAAAA...
replaceTextToExcelAction*ObjectAction configuration. Must contain phrases (array of replacement objects). Each object: searchText (string), replacementText (string, can be empty to delete), isExpression (bool, default: false), caseSensitive (bool, default: false), matchEntireCell (bool, default: false). Optional formatting objectSee Payload example below

Optional Parameters (inside replaceTextToExcelAction)

ParameterTypeDescriptionExample
cultureNameStringCulture code for processingen-US

Output

The API returns the Excel document as a Base64-encoded string in JSON format (document, fileName, success, errorMessage).

Request Example

Content-Type: application/json
Authorization: Basic YOUR_BASE64_ENCODED_API_KEY

Payload (Basic)

{
"document": { "Name": "data.xlsx" },
"docContent": "UEsDBBQABgAIAAAA...",
"replaceTextToExcelAction": {
"phrases": [
{ "searchText": "old", "replacementText": "new" }
]
}
}

Code Samples

Get Help