How can we convert the Excel chart to chart control?
We do not have direct support for converting Excel charts to chart controls. However, we can do it manually by using both XlsIO and Essential Chart. You can enumerate the elements of an XlsIO chart and draw the chart with the equivalent chart using Essential Chart. The code below illustrates the basic conversion of an XlsIO Chart to an Essential Chart:
C#
IChart chart = workbook.Charts.Add(); this.chartControl1.Text = chart.ChartTitle; for (int i =0; i < chart.Series.Count; i++) { ChartSeries ser = new ChartSeries(); int h = 0; int col=chart.Series[i].Values.Column; for (int j = chart.Series[i].Values.Row; j < chart.Series[i].Values.Count + chart.Series[i].Values.Row; j++) { h++; ser.Points.Add(h,chart.Series[i].Values[j, col].Number); } ser.Style.Interior = new ser.Name = ser.Text = chart.Series[i].Name; this.chartControl1.Series.Add(ser); }
VB
Dim chart As IChart = workbook.Charts.Add() Me.chartControl1.Text = chart.ChartTitle For i As Integer = 0 To chart.Series.Count - 1 Dim ser As ChartSeries = New ChartSeries() Dim h As Integer = 0 Dim col As Integer = chart.Series(i).Values.Column For j As Integer = chart.Series(i).Values.Row To chart.Series(i).Values.Count + chart.Series(i).Values.Row - 1 h += 1 ser.Points.Add(h,chart.Series(i).Values(j, col).Number) Next j ser.Text = chart.Series(i).Name Dim TempName As ser.Name = New ser.Name = ser.Text ser.Style.Interior = New ser.Name Me.chartControl1.Series.Add(ser) Next i
Here is the sample for your reference:
https://www.syncfusion.com/downloads/support/directtrac/87766/XlsIO_ChartControl652608821.zip
Take a moment to peruse the documentation where you can find basic Excel document processing options along with the features like import and export data, chart, formulas, conditional formatting, data validation, tables, pivot tables and protect the Excel documents, and most importantly, the PDF, CSV and Image conversions with code examples.
Conclusion
I hope you enjoyed learning about how can we convert the Excel chart to chart control.
You can refer to our XIsIO’s feature tour page to learn about its other groundbreaking features. Explore our UG documentation and online demos to understand how to manipulate data in Excel documents.
If you are an existing user, you can access our latest components from the License and Downloads page. For new users, you can try our 30-day free trial to check out XlsIO and other Syncfusion® components.
If you have any queries or require clarification, please let us know in the comments below or contact us through our support forums, Support Tickets, or feedback portal. We are always happy to assist you!