Hinzufügen eines Diagramms zu einem Arbeitsblatt Dieser REST API gibt an, dass dem Arbeitsblatt ein neues Diagramm hinzugefügt werden soll.
RSET API
Copy
PUT http://api.aspose.cloud/v3.0/cells/{ name} /worksheets/{ sheetName} /charts
Die Anforderungsparameter sind:
Parametername
Typ
Pfad/Abfragezeichenfolge/HTTPBody
Beschreibung
Name
Schnur
Weg
Name der Arbeitsmappe.
Blattname
Schnur
Weg
Der Arbeitsblattname.
Diagrammtyp
Schnur
Abfrage
Diagrammtyp, siehe Eigenschaftstyp in der Diagrammressource.
obereLinkeZeile
ganze Zahl
Abfrage
0
obere linke Spalte
ganze Zahl
Abfrage
0
untereRechteReihe
ganze Zahl
Abfrage
0
untereRechteSpalte
ganze Zahl
Abfrage
0
Bereich
Schnur
Abfrage
Gibt die Werte an, aus denen die Datenreihe dargestellt werden soll.
istVertikal
Boolescher Wert
Abfrage
WAHR
KategorieDaten
Schnur
Abfrage
Ruft den Wertebereich der Kategorieachse ab oder legt ihn fest. Es kann sich um einen Zellbereich handeln (z. B. “d1:e10”).
isAutoGetSerialName
Boolescher Wert
Abfrage
WAHR
Titel
Schnur
Abfrage
Gibt den Diagrammtitelnamen an.
Ordner
Schnur
Abfrage
Der Arbeitsmappenordner.
Speichername
Schnur
Abfrage
Speichername.
Datenbeschriftungen
Boolescher Wert
Abfrage
WAHR
dataLabelsPosition
Schnur
Abfrage
Über
PivotTableSheet
Schnur
Abfrage
PivotTableName
Schnur
Abfrage
DerOpenAPI-Spezifikation definiert eine öffentlich zugängliche Programmierschnittstelle und ermöglicht Ihnen die Durchführung von REST-Interaktionen direkt von einem Webbrowser aus.
Mit dem Befehlszeilentool cURL können Sie problemlos auf die Webdienste Aspose.Cells zugreifen. Das folgende Beispiel zeigt, wie Sie mit cURL Aufrufe an die Cloud API tätigen.
Cloud SDK-Familie
Die Verwendung eines SDKs beschleunigt die Entwicklung am besten. Ein SDK kümmert sich um grundlegende Details und ermöglicht Ihnen, sich auf Ihre Projektaufgaben zu konzentrieren. Bitte beachten Sie dieGitHub-Repository für eine vollständige Liste der Aspose.Cells Cloud SDKs.
Die folgenden Codebeispiele zeigen, wie Sie mithilfe verschiedener SDKs Aufrufe an Aspose.Cells-Webdienste tätigen:
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