Set Range Style – Aspose.Cells Cloud API Introduction
This example demonstrates how to set the style of a range using the Aspose.Cells Cloud API. You can call the API from many programming languages, such as .NET, Java, PHP, Ruby, Python, JavaScript (jQuery), and others.
API
Type
Description
Resource Link
/cells/{name}/worksheets/{sheetName}/ranges/style
POST
Set the cell style of a named range
PostWorksheetCellsRangeStyle
cURL Example
Request
Prerequisites
Obtain an access token via the OAuth2 client‑credentials flow (POST https://api.aspose.cloud/connect/token).
Include the header Authorization: Bearer <access_token> in every request.
Request
curl -X POST "https://api.aspose.cloud/v3.0/cells/test.xlsx/worksheets/Sheet1/ranges/style" \
-H "accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <access_token>" \
-d '{
"Range": {
"FirstRow": 1,
"FirstColumn": 1,
"RowCount": 2,
"ColumnCount": 2,
"Worksheet": "Sheet1"
},
"Style": {
"Font": {
"IsBold": true,
"IsItalic": true,
"IsStrikeout": true,
"IsSubscript": true,
"IsSuperscript": true,
"DoubleSize": 1
}
}
}'
The Range object specifies the top‑left cell and the size of the range. The Style object contains the formatting options to apply.
Response
Response
{
"Code" : 200 ,
"Status" : "OK"
}
Error handling – For unsuccessful calls the API returns an appropriate HTTP status code (e.g., 400, 401, 500) together with a JSON body that includes Error and Message fields. Inspect the Code value; any non‑200 result should be logged and processed according to your error‑handling policy.
SDK Source
The Aspose.Cells Cloud SDKs can be downloaded from the following page: Available SDKs
SDK Examples