Excel Charts


I need to be able to create a chart that contains 2 Nseries that display as vertical bars, and one NSeries that displays as a line chart, on the 2nd Y axis. Based on tth documentation all I need to do is

chart.NSeries(2).Type = ChartType.Line

to cause it to be a line chart, and

chart.NSeries(2).PlotOnSecondAxis = True

to cause it to be on the 2nd axis. Hower it jsut seems to ignore these options and gives me 3 vertical bars on the primary axis. Please let me know if I am missiing some steps. Also, I was not able to find any example code in the demos to create a chart with mixed types, It minght be helpfull for others if a chart like this was included.


Please try this attached version with following sample code:

Dim excel As Workbook = New Workbook()

Dim sheet As Worksheet = excel.Worksheets(0)

Dim cells As Cells = sheet.Cells




Dim index As Integer = sheet.Charts.Add(ChartType.Column,10,10,20,15)
Dim chart As Chart = sheet.Charts(index)
chart.NSeries.Add("A2:C4", False)
chart.NSeries(2).Type = ChartType.Line
chart.NSeries(2).PlotOnSecondAxis = True

chart.SecondValueAxis.IsVisible = True



Awesome, this worked perfectly. The only line i was missing was setting the SecondAxis.IsVisible to true.

Would I correct in assuming that you can only have one chart type per Axis, and that because I hadn't made the 2nd axis visible the line chart was displaying in the primary axis as whatever type it was defined as?

Thanks for the help. You guys make great tools.


With this new version, it will work fine even you don't set SecondAxis.IsVisible to true.

Currently Aspose.Cells only supports custom charts combined with Pie, Line, Column and ColumnStack type. And each chart can only contain two different types of series.