Aggiungi un grafico in un foglio di lavoro Questo REST API indica l’aggiunta di un nuovo grafico al foglio di lavoro.
RSETAPI
Copy
PUT http://api.aspose.cloud/v3.0/cells/{ name} /worksheets/{ sheetName} /charts
I parametri della richiesta sono:
Nome del parametro
Tipo
Percorso/Stringa di query/Corpo HTTP
Descrizione
nome
corda
sentiero
Nome della cartella di lavoro.
nomefoglio
corda
sentiero
Il nome del foglio di lavoro.
chartType
corda
domanda
Tipo di grafico, fare riferimento alla proprietà Tipo nella risorsa grafico.
riga superioresinistra
numero intero
domanda
0
colonna superiore sinistra
numero intero
domanda
0
LowerRightRow
numero intero
domanda
0
colonna inferiore destra
numero intero
domanda
0
la zona
corda
domanda
Specifica i valori da cui tracciare la serie di dati.
è verticale
booleano
domanda
VERO
categoriaDati
corda
domanda
Ottiene o imposta l’intervallo di valori della categoria Axis. Può essere un intervallo di celle (ad esempio “d1:e10”).
isAutoGetSerialName
booleano
domanda
VERO
titolo
corda
domanda
Specifica il nome del titolo del grafico.
cartella
corda
domanda
La cartella della cartella di lavoro.
storageName
corda
domanda
nome dell’archivio.
etichettedati
booleano
domanda
VERO
datiLabelsPosizione
corda
domanda
Sopra
pivotTableSheet
corda
domanda
NomeTabellaPivot
corda
domanda
ILSpecifiche OpenAPI definisce un’interfaccia di programmazione accessibile pubblicamente e consente di eseguire interazioni REST direttamente da un browser web.
È possibile utilizzare lo strumento da riga di comando cURL per accedere facilmente ai servizi Web Aspose.Cells. Nell’esempio seguente viene illustrato come effettuare chiamate al Cloud API con cURL.
Famiglia di SDK Cloud
Utilizzare un SDK è il modo migliore per accelerare lo sviluppo. Un SDK si prende cura dei dettagli di basso livello e ti consente di concentrarti sulle attività del tuo progetto. Si prega di controllare ilRepositorio GitHub per un elenco completo degli SDK Cloud Aspose.Cells.
I seguenti esempi di codice dimostrano come effettuare chiamate ai servizi Web Aspose.Cells utilizzando vari 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