This tutorial contains information on how to replace text in Excel using Python REST API. It assists to find and replace text in Excel using Python RESTful Service using a Python-based Cloud SDK. You will get a complete process to select target files, find and replace text and download the new files with replaced text on the disk.
Prerequisite
- Create an account and get API credentials for replacing text
- Download Aspose.Cells Cloud SDK for Python to find and replace text in a single or multiple Excel files
- Setup Python project with the above SDK
Steps to Search and Replace Text in Excel using Python REST API
- Define the App Client ID, Secret, and Aspose Cloud API endpoint
- Create an instance of CellsApi with the specified credentials
- Initialize a dictionary to hold Excel file names and their streams
- Search all .xlsx files within the current directory and its subfolders
- Read each Excel file and add its name and stream to the dictionary
- Build a PostReplaceRequest with the files, search text, and replacement text
- Call the API PostReplace to replace the text across all uploaded Excel files
- Convert Base64 results back to streams and save them as output files
These steps summarize the process of how to replace text in Excel using Python Low Code API. The code authenticates with Aspose.Cells Cloud API, reads all .xlsx files from the current directory and subfolders, and sends them for text replacement using a specified original and replacement word. It then decodes the modified files from Base64 and saves them locally with updated content.
Code to Find and Replace Text in Excel using Python Low Code API
The above code demonstrates how to find and replace text in Excel using Python Low Code API. This code creates new files in Cloud storage after performing the text replacement operation. It also stores files where no replacements were made, helping you maintain a complete repository of both modified and unmodified files.
This article has taught us the process of finding and replacing text. To find and extract text in Excel files, refer to the article Search Text in Excel using Python REST API.