Set Cell Formula in Excel Worksheets This REST API sets a cell formula in an Excel file.
REST API
POST https://api.aspose.cloud/v3.0/cells/{ name} /worksheets/{ sheetName} /cells/{ cellName}
Security and Authentication
The Aspose.Cells Cloud APIs are secure and require JWT token-based authentication .
Request parameters
Parameter Name
Type
Location
Required
Description
name
string
path
Y
Name of the Excel document.
sheetName
string
path
Y
Name of the worksheet.
cellName
string
path
Y
Address of the target cell (e.g., A1 ).
value
string
query
N
Value to assign to the cell.
type
string
query
N
Data type of the value (e.g., string ).
formula
string
query
N
Formula to apply to the cell (e.g., sum(A1,A2) ).
folder
string
query
N
Folder that contains the document.
storageName
string
query
N
Name of the storage service.
Response
Return CellResponse.
Field
Type
Description
Name
string
Address of the cell (e.g., F341).
Row
integer
Zero‑based row index.
Column
integer
Zero‑based column index.
Value
string
The cell’s displayed value.
Type
string
Data type of the cell (e.g., IsString).
Formula
string
Formula text if the cell contains a formula.
IsFormula
bool
Indicates whether the cell contains a formula.
IsMerged
bool
Indicates whether the cell is part of a merged range.
IsArrayHeader
bool
Indicates whether the cell is an array header.
IsInArray
bool
Indicates whether the cell belongs to an array.
IsErrorValue
bool
Indicates whether the cell contains an error value.
IsInTable
bool
Indicates whether the cell is inside a table.
IsStyleSet
bool
Indicates whether a style is applied to the cell.
HtmlString
string
HTML‑encoded representation of the cell’s value.
Style.link
object
Hyperlink to the style resource.
{
"Status" : "OK" ,
"Code" : 200 ,
"Cell" :{
"Name" : "A1" ,
"Row" : 0 ,
"Column" : 0 ,
"Value" : "" ,
"Type" : "String" ,
"Formula" : "=Sum(A2:A15)" ,
...
}
}
Http Status Codes
Code
Meaning
Description
200
OK
Compression succeeded; response contains compressed file details.
400
Bad Request
Missing or invalid parameters (e.g., unsupported file type).
401
Unauthorized
Invalid or missing JWT token.
413
Payload Too Large
Uploaded file exceeds size limit.
500
Internal Server Error
Unexpected server error.
How to Use the PostWorksheetCellSetValue API with SDKs
PostWorksheetCellSetValue API Specification
The OpenAPI Specification defines a publicly accessible programming interface and lets you carry out REST interactions directly from a web browser.
Use the cURL command‑line tool to call Aspose.Cells web services.
Use Aspose.Cells Cloud SDKs
Using an SDK is the best way to speed up development. An SDK handles low‑level details so you can focus on your project tasks. Please check out the GitHub repository for a complete list of Aspose.Cells Cloud SDKs.
The following code examples demonstrate how to make calls to Aspose.Cells web services using various SDKs:
C#
// C# example – set formula for a cell
// Replace <access-token>, <file-name>, etc. with your values.
var api = new CellsApi ( "<client-id>" , "<client-secret>" , "https://api.aspose.cloud" );
var response = api . PostWorksheetCellSetValue (
name : "myWorkbook.xlsx" ,
sheetName : "Sheet1" ,
cellName : "A3" ,
value : "1234" ,
type : "string" ,
formula : "SUM(A1,A2)" ,
folder : null ,
storageName : null );
Console . WriteLine ( response . Status );
Java
// Java example – set formula for a cell
CellsApi api = new CellsApi ( "<client-id>" , "<client-secret>" , "https://api.aspose.cloud" );
PostWorksheetCellSetValueRequest request = new PostWorksheetCellSetValueRequest ()
. name ( "myWorkbook.xlsx" )
. sheetName ( "Sheet1" )
. cellName ( "A3" )
. value ( "1234" )
. type ( "string" )
. formula ( "SUM(A1,A2)" );
CellsResponse response = api . postWorksheetCellSetValue ( request );
System . out . println ( response . getStatus ());
PHP
<? php
// PHP example – set formula for a cell
require_once ( 'vendor/autoload.php' );
$config = new Aspose\Cells\Configuration ();
$config -> setAppKey ( '<client-id>' );
$config -> setAppSid ( '<client-secret>' );
$config -> setHost ( 'https://api.aspose.cloud' );
$apiInstance = new Aspose\Cells\Api\CellsApi ( $config );
$result = $apiInstance -> postWorksheetCellSetValue (
"myWorkbook.xlsx" ,
"Sheet1" ,
"A3" ,
"1234" ,
"string" ,
"SUM(A1,A2)"
);
echo $result -> getStatus ();
?>
Ruby
# Ruby example – set formula for a cell
require 'aspose_cells_cloud'
config = AsposeCellsCloud :: Configuration . new
config . api_key [ 'client_id' ] = '<client-id>'
config . api_key [ 'client_secret' ] = '<client-secret>'
config . host = 'https://api.aspose.cloud'
api = AsposeCellsCloud :: CellsApi . new
result = api . post_worksheet_cell_set_value (
name : 'myWorkbook.xlsx' ,
sheet_name : 'Sheet1' ,
cell_name : 'A3' ,
value : '1234' ,
type : 'string' ,
formula : 'SUM(A1,A2)'
)
puts result . status
Python
# Python example – set formula for a cell
import asposecellscloud
client = asposecellscloud . CellsApiClient (
client_id = '<client-id>' ,
client_secret = '<client-secret>' ,
base_url = 'https://api.aspose.cloud'
)
api = asposecellscloud . CellsApi ( client )
response = api . post_worksheet_cell_set_value (
name = 'myWorkbook.xlsx' ,
sheet_name = 'Sheet1' ,
cell_name = 'A3' ,
value = '1234' ,
type = 'string' ,
formula = 'SUM(A1,A2)'
)
print ( response . status )
Node.js
// Node.js example – set formula for a cell
const { CellsApi , ApiClient } = require ( 'asposecellscloud' );
const client = new ApiClient ();
client . config = {
clientId : '<client-id>' ,
clientSecret : '<client-secret>' ,
baseUrl : 'https://api.aspose.cloud'
};
const cellsApi = new CellsApi ( client );
cellsApi . postWorksheetCellSetValue ({
name : 'myWorkbook.xlsx' ,
sheetName : 'Sheet1' ,
cellName : 'A3' ,
value : '1234' ,
type : 'string' ,
formula : 'SUM(A1,A2)'
}). then ( res => console . log ( res . status ));
Android
// Android (Java) example – set formula for a cell
// Similar to the standard Java example; ensure you use the Android-compatible SDK.
Swift
Swift example not available . The SDK for Swift is currently under development.
Perl
# Perl example – set formula for a cell
use AsposeCellsCloud::CellsApi ;
my $api_instance = AsposeCellsCloud::CellsApi -> new (
client_id => '<client-id>' ,
client_secret => '<client-secret>' ,
base_url => 'https://api.aspose.cloud'
);
my $result = $api_instance -> post_worksheet_cell_set_value (
name => 'myWorkbook.xlsx' ,
sheet_name => 'Sheet1' ,
cell_name => 'A3' ,
value => '1234' ,
type => 'string' ,
formula => 'SUM(A1,A2)'
);
print $result -> { Status };
Go
// Go example – set formula for a cell
package main
import (
"fmt"
"github.com/asposecellscloud/asposecellscloud-go/v3"
)
func main () {
config := asposecellscloud . NewConfiguration ()
config . ClientId = "<client-id>"
config . ClientSecret = "<client-secret>"
config . BasePath = "https://api.aspose.cloud"
api := asposecellscloud . NewAPIClient ( config ). CellsApi
resp , _ , err := api . PostWorksheetCellSetValue (
"myWorkbook.xlsx" ,
"Sheet1" ,
"A3" ,
map [ string ] string {
"value" : "1234" ,
"type" : "string" ,
"formula" : "SUM(A1,A2)" ,
},
nil ,
nil ,
)
if err != nil {
fmt . Println ( err )
return
}
fmt . Println ( resp . Status )
}