Skip to content

Commit 0ab6f3b

Browse files
997816-UpdateSupportedChartsDev
1 parent 32cc06c commit 0ab6f3b

File tree

2 files changed

+61
-27
lines changed

2 files changed

+61
-27
lines changed

Document-Processing/Excel/Conversions/Chart-to-Image/NET/Chart-to-Image-Conversion.md

Lines changed: 45 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,30 +19,36 @@ The following code snippet shows how to convert an Excel chart to an image using
1919
{% 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" %}
2020
using (ExcelEngine excelEngine = new ExcelEngine())
2121
{
22-
IApplication application = excelEngine.Excel;
23-
application.DefaultVersion = ExcelVersion.Xlsx;
22+
//Initialize application
23+
IApplication application = excelEngine.Excel;
2424

25-
// Initialize XlsIORenderer
26-
application.XlsIORenderer = new XlsIORenderer();
25+
//Set the default version as Xlsx
26+
application.DefaultVersion = ExcelVersion.Xlsx;
2727

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

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

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

37-
#region Save
38-
//Saving the workbook
39-
FileStream outputStream = new FileStream(Path.GetFullPath("Output/Image.png"), FileMode.Create, FileAccess.Write);
40-
chart.SaveAsImage(outputStream);
41-
#endregion
37+
//Open existing workbook with chart
38+
IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx"));
39+
IWorksheet worksheet = workbook.Worksheets[0];
40+
41+
//Access the chart from the worksheet
42+
IChart chart = worksheet.Charts[0];
4243

43-
//Dispose streams
44-
outputStream.Dispose();
45-
inputStream.Dispose();
44+
#region Save
45+
//Exporting the chart as image
46+
FileStream outputStream = new FileStream(Path.GetFullPath("Output/Image.png"), FileMode.Create, FileAccess.Write);
47+
chart.SaveAsImage(outputStream);
48+
#endregion
49+
50+
//Dispose streams
51+
outputStream.Dispose();
4652
}
4753
{% endhighlight %}
4854

@@ -177,7 +183,9 @@ Line
177183
<td>
178184
* Line<br/>
179185
* Line_Markers<br/>
180-
* Line_3D
186+
* Line_3D<br/>
187+
* Stacked_Line<br/>
188+
* Stacked_Line_Markers
181189
</td>
182190
</tr>
183191
<tr>
@@ -188,7 +196,8 @@ Pie
188196
* Pie<br/>
189197
* Pie_Exploded<br/>
190198
* Pie_3D<br/>
191-
* Pie_Exploded_3D
199+
* Pie_Exploded_3D<br/>
200+
* PieOfPie
192201
</td>
193202
</tr>
194203
<tr>
@@ -219,22 +228,35 @@ Stock
219228
</td>
220229
<td>
221230
* Stock_HighLowClose<br/>
222-
* Stock_OpenHighLowClose
231+
* Stock_OpenHighLowClose<br/>
232+
* Stock_VolumeOpenHighLowClose<br/>
233+
* Stock_VolumeHighLowClose
223234
</td>
224235
</tr>
225236
<tr>
226237
<td>
227238
Excel 2016 Charts
228239
</td>
229240
<td>
230-
* Funnel<br/>* Waterfall<br/>* Histogram<br/>* Pareto<br/></td>
241+
* Funnel<br/>
242+
* Waterfall<br/>
243+
* Histogram<br/>
244+
* Pareto<br/>
245+
* Sunburst<br/>
246+
* Box and Whisker<br/>
247+
* Treemap
248+
</td>
231249
</tr>
232250
</table>
233251

234-
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.
252+
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.
235253

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

256+
N> Waterfall charts are supported in both .NET Framework and .NET Core platforms for chart to image conversion.
257+
258+
N> Pie of Pie, Sunburst, Box and Whisker, and Treemap charts are supported only in .NET Core platforms for chart to image conversion.
259+
238260
## Supported chart elements
239261
XlsIO supports the following chart elements in image conversion:
240262
![Chart to Image Conversion](Working-With-Charts_images/chart-elements.jpeg)

Document-Processing/Excel/Conversions/Chart-to-Image/overview.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,8 @@ Pie
188188
* Pie<br/>
189189
* Pie_Exploded<br/>
190190
* Pie_3D<br/>
191-
* Pie_Exploded_3D
191+
* Pie_Exploded_3D<br/>
192+
* PieOfPie
192193
</td>
193194
</tr>
194195
<tr>
@@ -229,14 +230,25 @@ Stock
229230
Excel 2016 Charts
230231
</td>
231232
<td>
232-
* Funnel<br/>* Waterfall<br/>* Histogram<br/>* Pareto<br/></td>
233+
* Funnel<br/>
234+
* Waterfall<br/>
235+
* Histogram<br/>
236+
* Pareto<br/>
237+
* Sunburst<br/>
238+
* Box and Whisker<br/>
239+
* Treemap
240+
</td>
233241
</tr>
234242
</table>
235243

236-
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.
244+
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.
237245

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

248+
N> Waterfall charts are supported in both .NET Framework and .NET Core platforms for chart to image conversion.
249+
250+
N> Pie of Pie, Sunburst, Box and Whisker, and Treemap charts are supported only in .NET Core platforms for chart to image conversion.
251+
240252
## Supported chart elements
241253
XlsIO supports the following chart elements in image conversion:
242254
![Chart to Image Conversion](NET/Working-With-Charts_images/chart-elements.jpeg)
@@ -248,4 +260,4 @@ XlsIO supports the following chart elements in image conversion:
248260
4. Data labels
249261
5. Grid lines
250262
6. Legend
251-
7. Trend line
263+
7. Trend line

0 commit comments

Comments
 (0)