Converting Chart to Image in SVG Format

Contents
[ ]

The following sample code explains how to use Aspose.Cells for Python via .NET to convert a chart into an SVG format image. The code loads the source Microsoft Excel file and then saves the first chart found on the first worksheet to SVG.

from aspose.cells import Workbook
from aspose.cells.drawing import ImageType
from aspose.cells.rendering import ImageOrPrintOptions
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET
# The path to the documents directory.
dataDir = RunExamples.GetDataDir(".")
# Create workbook object from source file
workbook = Workbook(dataDir + "SampleChartBook.xlsx")
# Access first worksheet
worksheet = workbook.worksheets[0]
# Access first chart inside the worksheet
chart = worksheet.charts[0]
# Set image or print options
opts = ImageOrPrintOptions()
opts.image_type = ImageType.SVG
# Save the chart to svg format
chart.to_image(dataDir + "Image_out.svg", opts)