Ajouter un graphique dans une feuille de calcul Ce REST API indique l’ajout d’un nouveau graphique à la feuille de calcul.
RSET API
Copy
PUT http://api.aspose.cloud/v3.0/cells/{ name} /worksheets/{ sheetName} /charts
Les paramètres de la requête sont :
Le nom du paramètre
Taper
Chemin/Chaîne de requête/HTTPBody
Description
nom
chaîne
chemin
Nom du classeur.
Nom de la feuille
chaîne
chemin
Le nom de la feuille de calcul.
type de graphique
chaîne
requête
Type de graphique, veuillez vous référer à la propriété Type dans la ressource graphique.
rangée supérieuregauche
entier
requête
0
colonne supérieuregauche
entier
requête
0
Ligne inférieureDroite
entier
requête
0
Colonne inférieure droite
entier
requête
0
zone
chaîne
requête
Spécifie les valeurs à partir desquelles tracer la série de données.
estVertical
booléen
requête
Vrai
catégorieDonnées
chaîne
requête
Obtient ou définit la plage des valeurs de l’axe de catégorie. Il peut s’agir d’une plage de cellules (telle que « d1:e10 »).
isAutoGetSerialName
booléen
requête
Vrai
titre
chaîne
requête
Spécifie le nom du titre du graphique.
dossier
chaîne
requête
Le dossier du classeur.
Nom de stockage
chaîne
requête
nom de stockage.
étiquettes de données
booléen
requête
Vrai
dataLabelsPosition
chaîne
requête
Au-dessus de
feuille de tableau croisé dynamique
chaîne
requête
NomTableauPivot
chaîne
requête
LeSpécification OpenAPI définit une interface de programmation accessible au public et vous permet d’effectuer des interactions REST directement depuis un navigateur Web.
Vous pouvez utiliser l’outil de ligne de commande cURL pour accéder facilement aux services Web Aspose.Cells. L’exemple suivant montre comment passer des appels vers le Cloud API avec cURL.
Famille de SDK Cloud
Utiliser un SDK est le meilleur moyen d’accélérer le développement. Un SDK prend en charge les détails de bas niveau et vous permet de vous concentrer sur les tâches de votre projet. Veuillez consulter leDépôt GitHub pour une liste complète des SDK Cloud Aspose.Cells.
Les exemples de code suivants montrent comment effectuer des appels vers les services Web Aspose.Cells à l’aide de divers SDK :
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.Request;
using System;
public partial class CellsApiExample
{
public void PutWorksheetAddChartExample()
{
CellsApi cellsApi = new CellsApi(Environment.GetEnvironmentVariable("CellsCloudTestClientId"), Environment.GetEnvironmentVariable("CellsCloudTestClientSecret"));
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 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 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 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 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 *
api = CellsApi(os.getenv('CellsCloudClientId'),os.getenv('CellsCloudClientSecret'),"v3.0",os.getenv('CellsCloudApiBaseUrl'))
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 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 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