Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,36 @@ The following code snippet shows how to convert an Excel chart to an image using
{% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/XlsIO-Examples/master/Chart%20to%20Image/Chart%20to%20Image/.NET/Chart%20to%20Image/Chart%20to%20Image/Program.cs,180" %}
using (ExcelEngine excelEngine = new ExcelEngine())
{
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Xlsx;
//Initialize application
IApplication application = excelEngine.Excel;

// Initialize XlsIORenderer
application.XlsIORenderer = new XlsIORenderer();
//Set the default version as Xlsx
application.DefaultVersion = ExcelVersion.Xlsx;

//Set converter chart image format to PNG
application.XlsIORenderer.ChartRenderingOptions.ImageFormat = ExportImageFormat.Png;
//Initialize XlsIORenderer
application.XlsIORenderer = new XlsIORenderer();

FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read);
IWorkbook workbook = application.Workbooks.Open(inputStream);
IWorksheet worksheet = workbook.Worksheets[0];
//Set converter chart image format to PNG or JPEG
application.XlsIORenderer.ChartRenderingOptions.ImageFormat = ExportImageFormat.Png;

IChart chart = worksheet.Charts[0];
//Set the chart image quality to best
application.XlsIORenderer.ChartRenderingOptions.ScalingMode = ScalingMode.Best;

#region Save
//Saving the workbook
FileStream outputStream = new FileStream(Path.GetFullPath("Output/Image.png"), FileMode.Create, FileAccess.Write);
chart.SaveAsImage(outputStream);
#endregion
//Open existing workbook with chart
IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx"));
IWorksheet worksheet = workbook.Worksheets[0];

//Access the chart from the worksheet
IChart chart = worksheet.Charts[0];

//Dispose streams
outputStream.Dispose();
inputStream.Dispose();
#region Save
//Exporting the chart as image
FileStream outputStream = new FileStream(Path.GetFullPath("Output/Image.png"), FileMode.Create, FileAccess.Write);
chart.SaveAsImage(outputStream);
#endregion

//Dispose streams
outputStream.Dispose();
}
{% endhighlight %}

Expand Down Expand Up @@ -177,7 +183,9 @@ Line
<td>
* Line<br/>
* Line_Markers<br/>
* Line_3D
* Line_3D<br/>
* Stacked_Line<br/>
* Stacked_Line_Markers
</td>
</tr>
<tr>
Expand All @@ -188,7 +196,8 @@ Pie
* Pie<br/>
* Pie_Exploded<br/>
* Pie_3D<br/>
* Pie_Exploded_3D
* Pie_Exploded_3D<br/>
* PieOfPie
</td>
</tr>
<tr>
Expand Down Expand Up @@ -219,22 +228,35 @@ Stock
</td>
<td>
* Stock_HighLowClose<br/>
* Stock_OpenHighLowClose
* Stock_OpenHighLowClose<br/>
* Stock_VolumeOpenHighLowClose<br/>
* Stock_VolumeHighLowClose
</td>
</tr>
<tr>
<td>
Excel 2016 Charts
</td>
<td>
* Funnel<br/>* Waterfall<br/>* Histogram<br/>* Pareto<br/></td>
* Funnel<br/>
* Waterfall<br/>
* Histogram<br/>
* Pareto<br/>
* Sunburst<br/>
* Box and Whisker<br/>
* Treemap
</td>
</tr>
</table>

N> From the above supported chart types table, Waterfall and Line_3D charts are not supported in chart to image conversion in .NET Standard 2.0 onwards.
N> From the above supported chart types table, Line_3D charts are not supported in chart to image conversion in .NET Standard 2.0 onwards.

N> Only embedded charts are supported in chart to image conversion. Chart sheets are not supported.

N> Waterfall charts are supported in both .NET Framework and .NET Core platforms for chart to image conversion.

N> Pie of Pie, Sunburst, Box and Whisker, and Treemap charts are supported only in .NET Core platforms for chart to image conversion.

## Supported chart elements
XlsIO supports the following chart elements in image conversion:
![Chart to Image Conversion](Working-With-Charts_images/chart-elements.jpeg)
Expand Down
20 changes: 16 additions & 4 deletions Document-Processing/Excel/Conversions/Chart-to-Image/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,8 @@ Pie
* Pie<br/>
* Pie_Exploded<br/>
* Pie_3D<br/>
* Pie_Exploded_3D
* Pie_Exploded_3D<br/>
* PieOfPie
</td>
</tr>
<tr>
Expand Down Expand Up @@ -229,14 +230,25 @@ Stock
Excel 2016 Charts
</td>
<td>
* Funnel<br/>* Waterfall<br/>* Histogram<br/>* Pareto<br/></td>
* Funnel<br/>
* Waterfall<br/>
* Histogram<br/>
* Pareto<br/>
* Sunburst<br/>
* Box and Whisker<br/>
* Treemap
</td>
</tr>
</table>

N> From the above supported chart types table, Waterfall and Line_3D charts are not supported in chart to image conversion in .NET Standard 2.0 onwards.
N> From the above supported chart types table, Line_3D charts are not supported in chart to image conversion in .NET Standard 2.0 onwards.

N> Only embedded charts are supported in chart to image conversion. Chart sheets are not supported.

N> Waterfall charts are supported in both .NET Framework and .NET Core platforms for chart to image conversion.

N> Pie of Pie, Sunburst, Box and Whisker, and Treemap charts are supported only in .NET Core platforms for chart to image conversion.

## Supported chart elements
XlsIO supports the following chart elements in image conversion:
![Chart to Image Conversion](NET/Working-With-Charts_images/chart-elements.jpeg)
Expand All @@ -248,4 +260,4 @@ XlsIO supports the following chart elements in image conversion:
4. Data labels
5. Grid lines
6. Legend
7. Trend line
7. Trend line