Replace text
The following example will show you how to replace text in a spreadsheet using key/value pairs.
Spreadsheets are any documents that follow the presentation OpenXML schema (Microsoft Excel, OpenOffice Math).
You can view the full Swagger documentation here.
Request
- cURL
- Javascript
- PHP
curl --location 'https://spreadsheet-api.doclabs.cloud/api/v1/MyDocumentName.xlsx/text/replace?storageName=MyBucketName' \
--header 'Content-Type: application/json' \
--header 'x-api-key: MY_API_KEY' \
--data '{
"data": {
"textIWantToFind": "replace with this",
"foo": "bar"
}
}'
var settings = {
"url": "https://spreadsheet-api.doclabs.cloud/api/v1/MyDocumentName.xlsx/text/replace?storageName=MyBucketName",
"method": "POST",
"timeout": 0,
"headers": {
"Content-Type": "application/json",
"x-api-key": "MY_API_KEY"
},
"data": JSON.stringify({
"data": {
"textIWantToFind": "replace with this",
"foo": "bar"
}
}),
};
$.ajax(settings).done(function (response) {
console.log(response);
});
<?php
$client = new Client();
$headers = [
'Content-Type' => 'application/json',
'x-api-key' => 'MY_API_KEY'
];
$body = '{
"data": {
"textIWantToFind": "replace with this",
"foo": "bar"
}
}';
$request = new Request('POST', 'https://spreadsheet-api.doclabs.cloud/api/v1/MyDocumentName.xlsx/text/replace?storageName=MyBucketName', $headers, $body);
$res = $client->sendAsync($request)->wait();
echo $res->getBody();
Response
{
"bucketName": "MyBucketName",
"contentPathName": "CopyOfTheOriginal.xlsx"
}