Save spreadsheet as Excel API : SaveSpreadsheetAs
Converts a spreadsheet in cloud storage to the specified format.
Interface Details
Endpoint
Copy PUT http://api.aspose.cloud/v4 .0 /cells/{name}/saveas
Function Description
This method accesses a spreadsheet file directly from cloud storage, converts it into the desired output format (e.g., XLSX, PDF, CSV), and returns the converted result without downloading the file to the local system.Ensure that the cloud storage configuration (such as access credentials and file path) is correctly set up.The conversion process happens entirely within the cloud environment, minimizing data transfer overhead and enhancing security by keeping sensitive data within the cloud infrastructure.If the source file does not exist, or if an error occurs during the conversion process, an appropriate exception will be thrown.Supported output formats depend on the underlying conversion service capabilities.
The request parameters of saveSpreadsheetAs API are:
Parameter Name
Type
Path/Query String/HTTPBody
Description
name
String
Path
(Required) The name of the workbook file to be converted.
format
String
Query
(Required) The desired output format (e.g., “Xlsx”, “Pdf”, “Csv”).
saveOptionsData
Class
Body
(Optional) Save options data. The default is null.
folder
String
Query
(Optional) The folder path where the workbook is stored. The default is null.
storageName
String
Query
(Optional) The name of the storage if using custom cloud storage. Use default storage if omitted.
outPath
String
Query
(Optional) The folder path where the workbook is stored. The default is null.
outStorageName
String
Query
Output file Storage Name.
fontsLocation
String
Query
Use Custom fonts.
regoin
String
Query
The spreadsheet region setting.
password
String
Query
The password for opening spreadsheet file.
Response Description
Copy {
"Name" : "CellsCloudResponse" ,
"Type" : "Class" ,
"IsAbstract" : false ,
"Properties" : [
{
"Name" : "Code" ,
"Nullable" : true ,
"ReadOnly" : false ,
"IsInherit" : false ,
"DataType" : {
"Identifier" : "Integer" ,
"Name" : "integer"
}
},
{
"Name" : "Status" ,
"Nullable" : true ,
"ReadOnly" : false ,
"IsInherit" : false ,
"DataType" : {
"Identifier" : "String" ,
"Name" : "string"
}
}
]
}
OpenAPI Specification
The OpenAPI Specification defines a publicly accessible programming interface and lets you carry out REST interactions directly from a web browser.
Excel API SDK
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
using Aspose.Cells.Cloud.SDK.Api;
using Aspose.Cells.Cloud.SDK.Model;
using Aspose.Cells.Cloud.SDK.Request;
using System;
using System.IO;
using System.Collections.Generic;
using Range = Aspose.Cells.Cloud.SDK.Model.Range;
public static class Example40_WorkbookSaveAs
{
public static void Run()
{
CellsApi cellsApi = new CellsApi("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
string localName = "Book1.xlsx";
string remoteName = "Book1.xlsx";
string remoteFolder = "TestData/In";
var format = "csv";
var newfilename = "OutResult/PostExcelSaveAs.csv";
var saveOptionsData = new SaveOptionsData()
{
Filename = newfilename
};
var request = new SaveSpreadsheetAsRequest(
name: remoteName,
format: format,
saveOptionsData: saveOptionsData,
folder: remoteFolder
);
cellsApi.SaveSpreadsheetAs(request);
}
}
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
package com.aspose.cloud.cells.api;
import com.aspose.cloud.cells.client.*;
import com.aspose.cloud.cells.model.*;
import com.aspose.cloud.cells.request.*;
import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
import java.io.File;
import java.util.HashMap;
public class ExampleSaveSpreadsheetAs {
private CellsApi api;
public ExampleSaveSpreadsheetAs(){
try {
api = new CellsApi(
System.getenv("CellsCloudClientId"),
System.getenv("CellsCloudClientSecret"),
"v3.0",
System.getenv("CellsCloudApiBaseUrl")
);
} catch (ApiException e) {
e.printStackTrace();
}
}
public void Run(){
try{
String localName = "Book1.xlsx";
String remoteName = "Book1.xlsx";
String remoteFolder = "TestData/In";
String format = "csv";
String newfilename = "OutResult/PostExcelSaveAs.csv";
UploadFileRequest uploadFileRequest = new UploadFileRequest();
uploadFileRequest.setPath( remoteFolder + "/" + remoteName );
uploadFileRequest.setStorageName( "");
HashMap<String,File> files = new HashMap<String,File>();
files.put( localName , new File(localName ));
uploadFileRequest.setUploadFiles(files);
cellsApi.uploadFile(uploadFileRequest);
SaveSpreadsheetAsRequest request = new SaveSpreadsheetAsRequest();
request.setName(remoteName);
request.setFormat(format);
SaveOptionsData saveOptionsData = new SaveOptionsData();
saveOptionsData.setFilename(newfilename);
request.setSaveOptionsData(saveOptionsData);
request.setFolder(remoteFolder);
this.api.saveSpreadsheetAs(request);
} catch (ApiException e) {
// TODO Auto-generated catch block
e.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
<?php
require_once('vendor\autoload.php');
use \Aspose\Cells\Cloud\Api\CellsApi;
use \Aspose\Cells\Cloud\Request\SaveSpreadsheetAsRequest;
$cellsApi = new CellsApi(getenv("CellsCloudClientId"),getenv("CellsCloudClientSecret"),"v3.0",getenv("CellsCloudApiBaseUrl"));
$localName = "Book1.xlsx";
$remoteName = "Book1.xlsx";
$remoteFolder = "TestData/In";
$format = "csv";
$newfilename = "outResult/PostExcelSaveAs.csv";
$saveOptionsData = new \Aspose\Cells\Cloud\Model\SaveOptionsData();
$saveOptionsData->setFilename($newfilename );
CellsApiTestBase::ready( $this->instance,$localName ,$remoteFolder . "/" . $remoteName , "");
$request = new SaveSpreadsheetAsRequest();
$request->setName( $remoteName);
$request->setFormat( $format);
$request->setSaveOptionsData( $saveOptionsData);
$request->setFolder( $remoteFolder);
$$cellsApi->saveSpreadsheetAs($request);
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
require 'openssl'
require 'bundler'
require 'aspose_cells_cloud'
@instance = AsposeCellsCloud::CellsApi.new(ENV['CellsCloudClientId'], ENV['CellsCloudClientSecret'],'v3.0',ENV['CellsCloudApiBaseUrl'])
local_name = 'Book1.xlsx'
remote_name = 'Book1.xlsx'
remote_folder = 'TestData/In'
format = "csv"
newfilename = "OutResult/PostExcelSaveAs.csv"
mapFiles = { }
mapFiles[local_name] = ::File.open(File.expand_path("TestData/"+local_name),"r")
uploadrequest = AsposeCellsCloud::UploadFileRequest.new( { :UploadFiles=>mapFiles,:path=>remote_folder })
@instance.upload_file(uploadrequest)
saveOptionsData = AsposeCellsCloud::SaveOptionsData.new(:Filename=>newfilename );
request = AsposeCellsCloud::SaveSpreadsheetAsRequest.new(:name=>remote_name,:format=>format,:saveOptionsData=>saveOptionsData,:folder=>remote_folder);
@instance.save_spreadsheet_as(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
var fs = require('fs');
var path = require('path');
const _ = require('asposecellscloud');
const cellsApi = new CellsApi(process.env.CellsCloudClientId, process.env.CellsCloudClientSecret,"v3.0",process.env.CellsCloudApiBaseUrl);
var localName = "Book1.xlsx"
var remoteName = "Book1.xlsx"
var remoteFolder = "TestData/In"
var localNameRequest = new model.UploadFileRequest();
localNameRequest.uploadFiles ={localName:fs.createReadStream(localPath + localName)};
localNameRequest.path = remoteFolder + "/" + remoteName ;
localNameRequest.storageName ="";
cellsApi.uploadFile(localNameRequest );
var format = "csv"
var newfilename = "OutResult/PostExcelSaveAs.csv"
var saveOptionsData = new model.SaveOptionsData();
saveOptionsData.filename = newfilename ;
var request = new model.SaveSpreadsheetAsRequest();
request.name = remoteName;
request.format = format;
request.saveOptionsData = saveOptionsData;
request.folder = remoteFolder;
return cellsApi.saveSpreadsheetAs(request).then((result) => {
expect(result.response.statusCode).to.equal(200);
});
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
import os
import sys
from asposecellscloud.apis.cells_api import CellsApi
from asposecellscloud.models import *
from asposecellscloud.requests import *
api = CellsApi(os.getenv('CellsCloudClientId'),os.getenv('CellsCloudClientSecret'),"v3.0",os.getenv('CellsCloudApiBaseUrl'))
local_name = 'Book1.xlsx'
remote_name = 'Book1.xlsx'
remote_folder = 'TestData/In'
format = 'csv'
newfilename = 'OutResult/PostExcelSaveAs.csv'
saveOptionsData = SaveOptionsData(filename= newfilename )
mapFiles = {
local_name: local_name
}
request = UploadFileRequest( mapFiles, remote_folder + '/' + remote_name,storage_name= '')
api.upload_file(request)
request = SaveSpreadsheetAsRequest( remote_name, format,save_options_data= saveOptionsData,folder= remote_folder)
api.save_spreadsheet_as(request)
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
use lib 'lib';
use strict;
use warnings;
use File::Slurp;
use MIME::Base64;
use AsposeCellsCloud::CellsApi;
my $config = AsposeCellsCloud::Configuration->new( client_id => $ENV{'CellsCloudClientId'}, client_secret => $ENV{'CellsCloudClientSecret'});
my $instance = AsposeCellsCloud::CellsApi->new(AsposeCellsCloud::ApiClient->new( $config));
my $localName = 'Book1.xlsx';
my $remoteName = 'Book1.xlsx';
my $remoteFolder = 'TestData/In';
my $upload_file_request = AsposeCellsCloud::Request::UploadFileRequest->new( 'UploadFiles'=>{ $localName => $localName } ,'path'=>$remoteFolder . '/' . $remoteName );
my $format = 'csv';
my $newfilename = 'outResult/PostExcelSaveAs.csv';
my $save_options_data = AsposeCellsCloud::Object::SaveOptionsData->new();
$save_options_data->{filename} = $newfilename ;
my $request = AsposeCellsCloud::Request::SaveSpreadsheetAsRequest->new();
$request->{name} = $remoteName;
$request->{format} = $format;
$request->{save_options_data} = $save_options_data;
$request->{folder} = $remoteFolder;
$instance->save_spreadsheet_as(request=> $request);
Go
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
package main
import (
"os"
asposecellscloud "github.com/aspose-cells-cloud/aspose-cells-cloud-go"
)
func main() {
instance := asposecellscloud.NewCellsApiService(os.Getenv("ProductClientId"), os.Getenv("ProductClientSecret"), "https://api.aspose.cloud", "v3.0")
localName := "Book1.xlsx"
remoteName := "Book1.xlsx"
remoteFolder := "TestData/In"
localNameRequest := new(asposecellscloud.UploadFileRequest)
localNameRequest.UploadFiles = make(map[string]string)
localNameRequest.UploadFiles[localName] = localName
localNameRequest.Path = remoteFolder + "/" + remoteName
localNameRequest.StorageName =""
instance.UploadFile(localNameRequest )
format := "csv"
newfilename := "OutResult/PostExcelSaveAs.csv"
var saveOptionsData = new(SaveOptionsData)
saveOptionsData.Filename = newfilename
request := new (asposecellscloud.SaveSpreadsheetAsRequest)
request.Name = remoteName
request.Format = format
request.SaveOptionsData = saveOptionsData
request.Folder = remoteFolder
_, httpResponse, err := instance.SaveSpreadsheetAs(request)
if err != nil {
t.Error(err)
} else if httpResponse.StatusCode < 200 || httpResponse.StatusCode > 299 {
t.Fail()
}
}