Convert chart to image Excel API : ConvertChartToImage
Converts a chart of spreadsheet on a local drive to image.
Interface Details
Endpoint
Copy PUT http://api.aspose.cloud/v4.0/cells/convert/chart/image
Function Description
This method reads a chart of spreadsheet file from the local file system, converts it into the desired image format (e.g., PNG, SVG, Tiff), and returns the converted result.The source file path and target format must be specified correctly.Ensure that the necessary permissions are in place to read the source file and write the converted file if applicable.The conversion process occurs entirely on the cloud server, eliminating the need for any cloud storage or external downloads.If the source file does not exist, is inaccessible, or if an error occurs during the conversion process, an appropriate exception will be thrown.Supported formats for conversion depend on the available libraries and their capabilities.
The request parameters of convertChartToImage API are:
Parameter Name
Type
Path/Query String/HTTPBody
Description
Spreadsheet
File
FormData
Upload spreadsheet file.
worksheet
String
Query
chartIndex
Integer
Query
format
String
Query
(Required) The desired image type (e.g., svg, png, jpg).
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
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_ConvertChartToImage
{
public static void Run()
{
CellsApi cellsApi = new CellsApi("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
string localName = "EmployeeSalesSummary.xlsx";
var format = "svg";
var request = new ConvertChartToImageRequest(
spreadsheet: "TestData/" + localName,
worksheet: "Sales",
chartIndex: 0,
format: format
);
cellsApi.ConvertChartToImage(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 ExampleConvertChartToImage {
private CellsApi api;
public ExampleConvertChartToImage(){
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 = "EmployeeSalesSummary.xlsx";
String format = "svg";
ConvertChartToImageRequest request = new ConvertChartToImageRequest();
request.setWorksheet("Sales");
request.setChartIndex(0);
request.setFormat(format);
request.setSpreadsheet("TestData/" + localName);
this.api.convertChartToImage(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\ConvertChartToImageRequest;
$cellsApi = new CellsApi(getenv("CellsCloudClientId"),getenv("CellsCloudClientSecret"),"v3.0",getenv("CellsCloudApiBaseUrl"));
$localName = "EmployeeSalesSummary.xlsx";
$format = "svg";
$request = new ConvertChartToImageRequest();
$request->setSpreadsheet( "TestData/" . $localName);
$request->setWorksheet( "Sales");
$request->setChartIndex( 0);
$request->setFormat( $format);
$$cellsApi->convertChartToImage($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 = 'EmployeeSalesSummary.xlsx'
format = "svg"
request = AsposeCellsCloud::ConvertChartToImageRequest.new(:Spreadsheet=>'TestData/' + local_name,:worksheet=>'Sales',:chartIndex=>0,:format=>format);
@instance.convert_chart_to_image(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 = "EmployeeSalesSummary.xlsx"
var format = "svg"
var request = new model.ConvertChartToImageRequest();
request.spreadsheet = "TestData/" + localName;
request.worksheet = "Sales";
request.chartIndex = 0;
request.format = format;
return cellsApi.convertChartToImage(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 = 'EmployeeSalesSummary.xlsx'
format = 'svg'
request = ConvertChartToImageRequest( 'TestData/' + local_name, 'Sales', 0, format)
api.convert_chart_to_image(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 = 'EmployeeSalesSummary.xlsx';
my $format = 'svg';
my $request = AsposeCellsCloud::Request::ConvertChartToImageRequest->new();
$request->{spreadsheet} = 'TestData/' . $localName;
$request->{worksheet} = 'Sales';
$request->{chart_index} = 0;
$request->{format} = $format;
$instance->convert_chart_to_image(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 := "EmployeeSalesSummary.xlsx"
format := "svg"
request := new (asposecellscloud.ConvertChartToImageRequest)
request.Spreadsheet = "TestData/" + localName
request.Worksheet = "Sales"
request.ChartIndex = int64(0)
request.Format = format
_, httpResponse, err := instance.ConvertChartToImage(request)
if err != nil {
t.Error(err)
} else if httpResponse.StatusCode < 200 || httpResponse.StatusCode > 299 {
t.Fail()
}
}