Wednesday, 24 October 2018 08:56

How to save Excel chart sheet to SVG in C#

Written by  support iceblue
Rate this item
(0 votes)

A ChartSheet represents a chart sheet. It is a worksheet that contains only a chart. This article will demonstrate how to convert a chart sheet to SVG stream by using Spire.XLS.

Firstly, view the sample Excel worksheets with two chart sheets.

How to save Excel chart sheet to SVG in C#

Convert all the chart sheets to SVG stream:

//load the document from file
Workbook workbook = new Workbook();
workbook.LoadFromFile("Sample.xlsx");

//call ToSVGStream(Stream stream) method to save each chart sheet to SVG stream 
for (int i = 0; i < workbook.Chartsheets.Count; i++)
{
    FileStream fs = new FileStream(string.Format("chartsheet-{0}.svg", i), FileMode.Create);
    workbook.Chartsheets[i].ToSVGStream(fs);
    fs.Flush();
    fs.Close();
}

Effective screenshot of the two chart sheets to SVG.

How to save Excel chart sheet to SVG in C#

//load the document from file
Workbook workbook = new Workbook();
workbook.LoadFromFile("Sample.xlsx");

//get the second chartsheet by name
ChartSheet cs = workbook.GetChartSheetByName("Chart2");

//save to SVG stream
FileStream fs = new FileStream(string.Format("chart2.svg"), FileMode.Create);
cs.ToSVGStream(fs);
fs.Flush();
fs.Close();

How to save Excel chart sheet to SVG in C#

Additional Info

  • tutorial_title: Save Excel chart sheet to SVG in C#
Last modified on Wednesday, 24 October 2018 09:00