Arbeiten mit ImportData Tas REST API
API
Typ
Beschreibung
Ressourcenlink
/Zellen/Aufgabe/Ausführen der Aufgabe
POST
Task ausführen
PostRunTask
DerOpenAPI-Spezifikation definiert eine öffentlich zugängliche Programmierschnittstelle und ermöglicht Ihnen die Durchführung von REST-Interaktionen direkt von einem Webbrowser aus.
Sie könnencURL Befehlszeilentool für den einfachen Zugriff auf Aspose.Cells-Webdienste. Das folgende Beispiel zeigt, wie Sie mit cURL Aufrufe an Cloud API tätigen.
Die Verwendung eines SDKs beschleunigt die Entwicklung am besten. Ein SDK kümmert sich um die Details auf niedriger Ebene und ermöglicht es 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#
View raw
(Sorry about that, but we can’t show files that are this big right now.)
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
<?php
# For complete examples and data files, please go to https://github.com/aspose-cells-cloud/aspose-cells-cloud-php
require_once('vendor\autoload.php');
use \Aspose\Cells\Cloud\Api\CellsApi;
use \Aspose\Cells\Cloud\Request\PostRunTaskRequest;
use \Aspose\Cells\Cloud\Model\TaskDescription;
use \Aspose\Cells\Cloud\Model\SplitWorkbookTaskParameter;
use \Aspose\Cells\Cloud\Model\FileSource;
use \Aspose\Cells\Cloud\Model\TaskData;
class Workbook {
public $instance;
public function __construct() {
$this->instance = new CellsApi(getenv("CellsCloudClientId"),getenv("CellsCloudClientSecret"),"v3.0",getenv("CellsCloudApiBaseUrl"));
}
public function postTaskDataMultipartContent() {
$name ='Book1.xlsx';
$sheet_name ='Sheet1';
$folder = "TestData/In";
$task1 = new TaskDescription();
$task1->setTaskType('SplitWorkbook');
$param1 = new SplitWorkbookTaskParameter ();
$param1->setDestinationFileFormat('xlsx');
$fileSource =new FileSource();
$fileSource->setFileSourceType('CloudFileSystem');
$param1->setDestinationFilePosition($fileSource);
$param1->setSplitNameRule('sheetname');
$workbook =new FileSource();
$workbook->setFilePath( $folder. "\\". $name);
$workbook->setFileSourceType('CloudFileSystem');
$param1->setWorkbook($workbook);
$task1->setTaskParameter($param1);
$taskData = new TaskData();
$tasks = array($task1);
$taskData->setTasks($tasks);
$request = new PostRunTaskRequest();
$request->setTaskData($taskData);
$result = $this->instance->postRunTask($request);
}
}
$workbook = new Workbook();
$workbook->postTaskDataMultipartContent();
?>
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 Workbook
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
def post_run_task
param1 = AsposeCellsCloud::SplitWorkbookTaskParameter.new({:DestinationFileFormat=>'xlsx' ,:DestinationFilePosition=> AsposeCellsCloud::FileSource.new({:FileSourceType=>'CloudFileSystem'}),:SplitNameRule=>'sheetname',:Workbook=>AsposeCellsCloud::FileSource.new({:FilePath=>$TEMPFOLDER +'\\' + $BOOK1,:FileSourceType=>'CloudFileSystem'})})
task1 =AsposeCellsCloud::TaskDescription.new({:TaskType=>'SplitWorkbook',:TaskParameter=>param1})
task_data = AsposeCellsCloud::TaskData.new(:Tasks=>[task1])
result = @instance.cells_task_post_run_task(task_data)
expect(result).not_to be_empty
end
end
workbook = Workbook.new()
puts workbook.post_run_task
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
const { CellsApi, UploadFileRequest, CellsTask_PostRunTaskRequest, TaskData, TaskDescription, SplitWorkbookTaskParameter, FileSource } = 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 CellsTask_PostRunTaskRequest();
const taskData = new TaskData();
taskData.tasks = new Array<model.TaskDescription>();
const task1 = new TaskDescription();
task1.taskType = "SplitWorkbook";
const param1 = new SplitWorkbookTaskParameter();
param1.destinationFileFormat = "xlsx";
const destinationFilePosition = new FileSource();
param1.destinationFilePosition.fileSourceType = "CloudFileSystem";
param1.splitNameRule = "sheetname";
param1.workbook = new model.FileSource();
param1.workbook.fileSourceType = "CloudFileSystem";
param1.workbook.filePath = "Temp" + "\\" + filename;
task1.taskParameter = param1;
taskData.tasks.push(task1);
req.taskData = taskData;
cellsApi.cellsTaskPostRunTask(req)
.then((result) => {
console.log("successful")
}).catch((error) => {
console.error('Unhandled Promise Rejection:', error);
})
})
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 $result =undef;
my $BOOK1 = 'Book1.xlsx';
my $MYDOC = 'myDocument.xlsx';
my $PVTESTFILE = 'TestCase.xlsx';
my $TEMPFOLDER = 'PerlTest';
my $SHEET1 = 'Sheet1';
my $SHEET2 = 'Sheet2';
my $SHEET3 = 'Sheet3';
my $SHEET4 = 'Sheet4';
my $SHEET5 = 'Sheet5';
my $SHEET6 = 'Sheet6';
my $SHEET7 = 'Sheet7';
my $SHEET8 = 'Sheet8';
my $CELLNAME = 'A1';
my $RANGE = 'A1:C10';
my $CELLAREA = 'A1:C10';
my $api = get_client();
my $name = $BOOK1; # replace NULL with a proper value
my @intarray = qw(1 2 3 4) ;
my $importdata = "<ImportBatchDataOption><DestinationWorksheet>Sheet1</DestinationWorksheet><IsInsert>false</IsInsert><ImportDataType>BatchData</ImportDataType><Source><FileSourceType>CloudSystem</FileSourceType><FilePath>Batch_data_xml_2.txt</FilePath></Source></ImportBatchDataOption>";
my $folder = $TEMPFOLDER; # replace NULL with a proper value
ready_file('api'=> $api, 'file'=>$name ,'folder' =>$folder) ;
$result = $api->cells_workbook_post_import_data(name => $name, importdata => $importdata, folder => $folder);
ok($result->status eq 'OK' ,'cells_workbook_post_import_data OK');