Add a pivot field into pivot table This REST API indicates to add
pivot field into into pivot table
RSET API
PUT http://api.aspose.cloud/v3.0/cells/{ name} /worksheets/{ sheetName} /pivottables/{ pivotTableIndex} /PivotField
The request parameters are:
Parameter Name
Type
Path/Query String/HTTPBody
Description
name
string
path
Document name.
sheetName
string
path
The worksheet name.
pivotTableIndex
integer
path
Pivot table index
pivotFieldType
string
query
The fields area type.
request
body
Dto that conrains field indexes
needReCalculate
boolean
query
False
folder
string
query
Document’s folder.
storageName
string
query
storage name.
The OpenAPI Specification defines a publicly accessible programming interface and lets you carry out REST interactions directly from a web browser.
You can use cURL command-line tool to access Aspose.Cells web services easily. The following example shows how to make calls to Cloud API with cURL.
Cloud SDK Family
Using an SDK is the best way to speed up the development. An SDK takes care of low-level details and lets you 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#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells-cloud/aspose-cells-cloud-dotnet/
namespace Aspose.Cells.Cloud.SDK.Example
{
using Aspose.Cells.Cloud.SDK.Api;
using Aspose.Cells.Cloud.SDK.Model;
using Aspose.Cells.Cloud.SDK.Request;
using System;
using System.Collections.Generic;
public partial class CellsApiExample
{
public void PutPivotTableFieldExample()
{
CellsApi cellsApi = new CellsApi(Environment.GetEnvironmentVariable("CellsCloudTestClientId"), Environment.GetEnvironmentVariable("CellsCloudTestClientSecret"));
PutPivotTableFieldRequest request = new PutPivotTableFieldRequest
{
name = "Book1.xlsx",
sheetName = "Sheet4",
pivotTableIndex = 0,
pivotFieldType = "Row",
pivotTableFieldRequest = new PivotTableFieldRequest
{
Data = new List<int?>() { 1 }
},
needReCalculate = true,
folder = "TestData/In"
};
cellsApi.PutPivotTableField(request);
}
}
}
// Obsolet
//CellsApi instance = new CellsApi(clientId, clientSecret, apiVersion, testbaseurl);
//string name = PivTestFile;
//string sheetName = SHEET4;
//int? pivotTableIndex = 0;
//string pivotFieldType = "Row";
//PivotTableFieldRequest request = new PivotTableFieldRequest();
//request.Data = new List<int?>() { 1};
//bool? needReCalculate = null;
//string folder = TEMPFOLDER;
//instance.UploadFile(folder + @"\" + name, File.Open( @"C:\TestData\" +name));
//var response = instance.CellsPivotTablesPutPivotTableField(name, sheetName, pivotTableIndex, pivotFieldType, request, needReCalculate, folder);
//Assert.IsInstanceOf<CellsCloudResponse>(response, "response is CellsCloudResponse");
//Assert.AreEqual(response.Code, 200);
Java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells-cloud/aspose-cells-cloud-java/
try {
CellsApi api = new CellsApi(System.getenv("CellsCloudTestClientId"),System.getenv("CellsCloudTestClientSecret"),"v3.0",System.getenv("CellsCloudTestApiBaseUrl"));
String remoteFolder = "TestData/";
String localName = "Book1.xlsx";
String remoteName = "Book1.xlsx";
PivotTableFieldRequest pivottable = new PivotTableFieldRequest();
List<Integer> data = new ArrayList<Integer>();
data.add(1);
pivottable.setData(data);
PutPivotTableFieldRequest request = new PutPivotTableFieldRequest();
request.setName(remoteName);
request.setSheetName("Sheet4");
request.setPivotTableIndex(0);
request.setPivotFieldType("Row");
request.setPivotTableFieldRequest(pivottable);
request.setNeedReCalculate(true);
request.setFolder(remoteFolder);
request.setStorageName("");
CellsCloudResponse response = api.putPivotTableField(request);
}
catch (Exception e) {
e.printStackTrace();
}
Ruby
Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# For complete examples and data files, please go to https://github.com/aspose-cells-cloud/aspose-cells-cloud-python
import os
from asposecellscloud.apis.cells_api import CellsApi
from asposecellscloud.requests import *
from asposecellscloud.models import *
api = CellsApi(os.getenv('CellsCloudClientId'),os.getenv('CellsCloudClientSecret'),"v3.0",os.getenv('CellsCloudApiBaseUrl'))
remote_name ='TestCase.xlsx'
remote_folder = "PythonTest"
pivotTableFieldRequestData = [
0
]
pivotTableFieldRequest = PivotTableFieldRequest(data= pivotTableFieldRequestData )
request = PutPivotTableFieldRequest( remote_name, 'Sheet4', 0, 'Row', pivotTableFieldRequest,need_re_calculate= True,folder= remote_folder,storage_name= '')
api.put_pivot_table_field(request)
Node.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { CellsApi, UploadFileRequest, CellsPivotTables_PutPivotTableFieldRequest, PivotTableFieldRequest } = require("asposecellscloud");
const clientId = process.env.CellsCloudClientId;
const clientSecret = process.env.CellsCloudClientSecret;
const ApiURL = process.env.CellsCloudApiBaseUrl;
const fs = require('fs');
const path = require('path');
const cellsApi = new CellsApi(clientId, clientSecret,"v3.0",ApiURL);
const localPath = "D:/aspose-cells-cloud-node/TestData/"
const filename = "Book1.xlsx";
const data =fs.createReadStream(path.join(localPath, filename));
const req = new UploadFileRequest({
path: "Temp/" + filename,
file: data
});
cellsApi.uploadFile(req)
.then((result) => {
const req = new CellsPivotTables_PutPivotTableFieldRequest();
req.name = filename;
req.sheetName = "Sheet4";
req.pivotTableIndex = 0;
req.pivotFieldType = "Row";
const request = new PivotTableFieldRequest();
req.request.data = [1];
req.needReCalculate = null;
req.folder = "Temp";
cellsApi.cellsPivotTablesPutPivotTableField(req)
.then((result) => {
console.log("successful")
}).catch((error) => {
console.error('Unhandled Promise Rejection:', error);
})
})
Android
Perl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# For complete examples and data files, please go to https://github.com/aspose-cells-cloud/aspose-cells-cloud-perl/
use strict;
use warnings;
use utf8;
use File::Slurp;
use MIME::Base64;
use AsposeCellsCloud::CellsApi;
my $config = AsposeCellsCloud::Configuration->new( client_id => $ENV{'ProductClientId'}, client_secret => $ENV{'ProductClientSecret'});
my $instance = AsposeCellsCloud::CellsApi->new(AsposeCellsCloud::ApiClient->new( $config));
my $remoteFolder = 'TestData/In';
my $remoteName = 'TestCase.xlsx';
my $style_font = AsposeCellsCloud::Object::Font->new();
$style_font->{size} = 16 ;
my $style = AsposeCellsCloud::Object::Style->new();
$style->{font} = $style_font ;
my $request = AsposeCellsCloud::Request::PostPivotTableStyleRequest->new();
$request->{name} = $remoteName;
$request->{sheet_name} = 'Sheet4';
$request->{pivot_table_index} = 0;
$request->{style} = $style;
$request->{need_re_calculate} = 'true';
$request->{folder} = $remoteFolder;
$request->{storage_name} = '';
my $result = $api->post_pivot_table_style(request=> $request);
Go