This guide explains how to add watermark in Excel using Python REST API. You will learn to automatically watermark Excel using Python REST Interface by utilizing a Python-based Cloud SDK. Various customization options will be discussed while inserting a watermark in the Excel file.
Prerequisite
- Create an account and get API credentials for inserting watermark text
- Download Aspose.Cells Cloud SDK for Python to add a watermark in an Excel file
- Setup a Python project with the above SDK
Steps to Insert Watermark in Excel using Python Low Code API
- Set the required clientId, clientSecret, and the base API URL to authenticate with Aspose.Cells Cloud
- Instantiate the CellsApi class using your API credentials and endpoint to access workbook-related operations
- Define the local Excel file name and upload it to Aspose Cloud storage using UploadFileRequest
- Create a TextWaterMarkerRequest object with the desired watermark text and the font size
- Send a PutWorkbookWaterMarkerRequest with the file name and watermark configuration to apply the watermark to the uploaded workbook
- Create a DownloadFileRequest for the same file and receive the modified file stream with the watermark applied
- Write the downloaded stream to a new file on the local machine using a file stream
These steps summarize how to add a watermark in Excel using Python REST Interface. The code authenticates with Aspose.Cells Cloud, uploads an Excel file, applies a text watermark using specified font settings, and then downloads the updated workbook. Finally, it saves the modified file locally as WatermarkedWorkbook.xlsx.
Code to Add Watermark to Excel Sheet using Python RESTful Service
The above code demonstrates how to apply watermark in Excel using Python RESTful Service. You can customize the watermark by setting the properties in the TextWaterMarkerRequest object, such as text and font size. You can upload multiple workbooks and repeat the PutWorkbookWaterMarker() command for each file by setting its name in the PutWorkbookWaterMarkerRequest object.
This article has taught us how to create a watermark in Excel using a Python-based API. To remove the image background from an Excel file, refer to the article Remove image background in Excel using Python REST API.