Add a Chart in a Worksheet This REST API indicates add a new chart to worksheet.
RSET API
Copy
PUT http://api.aspose.cloud/v3.0/cells/{ name} /worksheets/{ sheetName} /charts
The request parameters are:
Parameter Name
Type
Path/Query String/HTTPBody
Description
name
string
path
Workbook name.
sheetName
string
path
The worksheet name.
chartType
string
query
Chart type, please refer property Type in chart resource.
upperLeftRow
integer
query
0
upperLeftColumn
integer
query
0
lowerRightRow
integer
query
0
lowerRightColumn
integer
query
0
area
string
query
Specifies values from which to plot the data series.
isVertical
boolean
query
True
categoryData
string
query
Gets or sets the range of category Axis values. It can be a range of cells (such as, “d1:e10”).
isAutoGetSerialName
boolean
query
True
title
string
query
Specifies chart title name.
folder
string
query
The workbook folder.
storageName
string
query
storage name.
dataLabels
boolean
query
True
dataLabelsPosition
string
query
Above
pivotTableSheet
string
query
pivotTableName
string
query
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 hidden or 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.Request;
using System;
public partial class CellsApiExample
{
public void PutWorksheetAddChartExample()
{
string CellsCloudClientId ="....";//get from https://dashboard.aspose.cloud/#/applications
string CellsCloudClientSecret="...";//get from https://dashboard.aspose.cloud/#/applications
PutWorksheetAddChartRequest request = new PutWorksheetAddChartRequest { name = "Book1.xlsx", sheetName = "Sheet4",
chartType="pie",
upperLeftRow = 5,
upperLeftColumn = 5,
lowerRightRow = 10,
lowerRightColumn = 10,
area = "C7:D11",
isVertical = true, folder = "TestData/In" };
cellsApi.PutWorksheetAddChart(request);
}
}
}
// Obsolet
//CellsApi instance = new CellsApi(clientId, clientSecret, apiVersion, testbaseurl);
//string name = MYDOC;
//string sheetName = SHEET4;
//string chartType = "Pie";
//int? upperLeftRow = 5;
//int? upperLeftColumn = 5;
//int? lowerRightRow = 10;
//int? lowerRightColumn = 10;
//string area = "C7:D11";
//bool? isVertical = true;
//string categoryData = null;
//bool? isAutoGetSerialName = null;
//string title = null;
//string folder = TEMPFOLDER;
//instance.UploadFile(folder + @"\" + name, File.Open( @"C:\TestData\" +name));
//var response = instance.CellsChartsPutWorksheetAddChart(name, sheetName, chartType, upperLeftRow, upperLeftColumn, lowerRightRow, lowerRightColumn, area, isVertical, categoryData, isAutoGetSerialName, title, folder);
//Assert.IsInstanceOf<ChartsResponse>(response, "response is ChartsResponse");
//Assert.AreEqual(response.Code, 200);
Java
This file contains hidden or 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";
PutWorksheetAddChartRequest request = new PutWorksheetAddChartRequest();
request.setName("myDocument.xlsx");
request.setSheetName("Sheet3");
request.setChartType("pie");
request.setUpperLeftRow(5);
request.setUpperLeftColumn(5);
request.setLowerRightRow(10);
request.setLowerRightColumn(10);
request.setArea("C7:D11");
request.setIsVertical(true);
request.setCategoryData("");
request.setIsAutoGetSerialName(false);
request.setTitle("");
request.setDataLabels(false);
request.setDataLabelsPosition("");
request.setPivotTableSheet("");
request.setPivotTableName("");
request.setFolder(remoteFolder);
request.setStorageName("");
CellsCloudResponse response = api.putWorksheetAddChart(request);
} catch (Exception ex) {
ex.printStackTrace();
}
PHP
This file contains hidden or 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-php
<?php
require_once('vendor\autoload.php');
use \Aspose\Cells\Cloud\Api\CellsApi;
use \Aspose\Cells\Cloud\Request\PutWorksheetChartRequest;
class Chart {
public $instance;
public function __construct() {
$this->instance = new CellsApi(getenv("CellsCloudClientId"),getenv("CellsCloudClientSecret"),"v3.0",getenv("CellsCloudApiBaseUrl"));
}
public function putWorksheetAddChart() {
$remoteFolder = "TestData/In";
$localName = "Book1.xlsx";
$remoteName = "Book1.xlsx";
$request = new PutWorksheetChartRequest();
$request->setName( $remoteName);
$request->setSheetName( "Sheet4");
$request->setChartType( "Pie");
$request->setUpperLeftRow( 5);
$request->setUpperLeftColumn( 5);
$request->setLowerRightRow( 10);
$request->setLowerRightColumn( 10);
$request->setArea( "C7:D11");
$request->setIsVertical( 'true');
$request->setTitle( "Aspose Chart");
$request->setFolder( $remoteFolder);
$request->setStorageName( "");
$this->instance->putWorksheetChart($request);
}
}
$instance = new Chart();
$instance->putWorksheetAddChart();
?>
Ruby
This file contains hidden or 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-ruby
require 'aspose_cells_cloud'
class Chart
include AsposeCellsCloud
def initialize
#Get client_id and client_secret from https://cloud.aspose.com
@instance = AsposeCellsCloud::CellsApi.new($client_id,$client_secret,$api_version,$baseurl)
end
# Add new chart to worksheet.
def add_new_chart_to_worksheet
name = $MYDOC
sheet_name = $SHEET3
chart_type = 'Pie'
upper_left_row = 5
upper_left_column = 5
lower_right_row = 10
lower_right_column = 10
area = $CELLAREA
is_vertical = true
category_data = nil
is_auto_get_serial_name = nil
title = nil
folder = $TEMPFOLDER
result = @instance.upload_file( folder+"/"+name, ::File.open(File.expand_path("data/"+name),"r") {|io| io.read(io.size) })
expect(result.uploaded.size).to be > 0
result = @instance.cells_charts_put_worksheet_add_chart(name, sheet_name, chart_type, { :upper_left_row=>upper_left_row, :upper_left_column=>upper_left_column, :lower_right_row=>lower_right_row, :lower_right_column=>lower_right_column, :area=>area, :is_vertical=>is_vertical, :folder=>folder})
expect(result.code).to eql(200)
end
end
chart = Chart.new()
puts chart.add_new_chart_to_worksheet
Python
This file contains hidden or 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 *
CellsCloudClientId ='....' # get from https://dashboard.aspose.cloud/#/applications
CellsCloudClientSecret='....' # get from https://dashboard.aspose.cloud/#/applications
api = CellsApi(CellsCloudClientId,CellsCloudClientSecret)
request = PutWorksheetChartRequest( 'myDocument.xlsx', 'Sheet3', 'Pie' ,upper_left_row= 5,upper_left_column= 5,lower_right_row= 10,lower_right_column= 10,area= 'C7:D11',is_vertical= True,title= 'Aspose Chart',folder= 'PythonTest',storage_name= '')
api.put_worksheet_chart(request)
Node.js
This file contains hidden or 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-node
import { expect } from "chai";
import "mocha";
import * as model from "../src/model/model";
import * as BaseTest from "./baseTest";
var fs = require('fs');
describe('cellsChartsPutWorksheetAddChart', function() {
it('should call cellsChartsPutWorksheetAddChart successfully', function() {
const cellsApi = new api.CellsApi(process.env.CellsCloudTestClientId, process.env.CellsCloudTestClientSecret,"v3.0",process.env.CellsCloudTestApiBaseUrl);
const filename = "myDocument.xlsx";
var data =fs.createReadStream(localPath + filename);
var req = new model.UploadFileRequest();
req.path = "Temp/" + filename;
req.file = data;
return cellsApi.uploadFile(req)
.then((result) => {
expect(result.body.uploaded.length).greaterThan(0);
var req = new model.CellsCharts_PutWorksheetAddChartRequest();
req.name = filename;
req.sheetName = "Sheet4";
req.chartType = "Pie";
req.upperLeftRow = 5;
req.upperLeftColumn = 5;
req.lowerRightRow = 10;
req.lowerRightColumn = 10;
req.area = "C7:D11";
req.isVertical = true;
req.isAutoGetSerialName = null;
req.folder = "Temp";
return cellsApi.cellsChartsPutWorksheetAddChart(req)
.then((result) => {
expect(result.body.code).to.equal(200);
expect(result.response.statusCode).to.equal(200);
});
});
});
});
Objective C
Perl
This file contains hidden or 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 = 'Book1.xlsx';
my $request = AsposeCellsCloud::Request::PutWorksheetAddChartRequest->new();
$request->{name} = $remoteName;
$request->{sheet_name} = 'Sheet4';
$request->{chart_type} = 'Pie';
$request->{upper_left_row} = 5;
$request->{upper_left_column} = 5;
$request->{lower_right_row} = 10;
$request->{lower_right_column} = 10;
$request->{area} = 'C7:D11';
$request->{is_vertical} = 'true';
$request->{title} = 'Aspose Chart';
$request->{folder} = $remoteFolder;
$request->{storage_name} = '';
my $result = $api->put_worksheet_add_chart(request=> $request);
Android
Go