Problem with Trend line Maker



I have written below code to generate trendlines.It is only generating lines not trend lines.

Can you pls check i need to add in my code to get trend lines.



Dim sheetIndex As Integer = excel.Worksheets.Add(SheetType.Chart)

Dim sheet2 As Worksheet = excel.Worksheets(sheetIndex)

sheet2.Name = "Balance Based Revenue Chart"

sheet2.Zoom = 75

Me.ReportPageSetUp(excel, sheet2)

Dim chartIndex As Integer = sheet2.Charts.Add(ChartType.Column, 5, 5, 20, 15)

Dim chart As chart = sheet2.Charts(chartIndex)

chart.Title.Text = "Trend Analysis Balance Based Revenue"

chart.Title.TextFont.Color = Color.Black

chart.Title.TextFont.Name = "Arial"

chart.Title.TextFont.Size = 12

chart.Title.TextFont.IsBold = True


chart.NSeries(0).Type = ChartType.Column

chart.NSeries(0).Name = "Number of Relationships"

chart.NSeries(1).TrendLines.Add(TrendlineType.Linear, "Float Revenue")

chart.NSeries(2).TrendLines.Add(TrendlineType.Linear, "Excess Balance Revenue")

chart.NSeries(3).TrendLines.Add(TrendlineType.Linear, "Sweep Balance Revenue")

chart.NSeries(4).TrendLines.Add(TrendlineType.Linear, "Over Draft Revenue")

chart.NSeries(5).TrendLines.Add(TrendlineType.Linear, "Other Balance Based Revenue")

'''Set Colors

chart.NSeries(0).Area.ForegroundColor = Color.Gray

chart.NSeries(0).Area.Formatting = FormattingType.Custom

Dim line As Trendline = chart.NSeries(1).TrendLines(0)

line.DisplayEquation = True

line.DisplayRSquared = True

line.Color = Color.Red

Dim line1 As Trendline = chart.NSeries(2).TrendLines(1)

line1.DisplayEquation = True

line1.DisplayRSquared = True

line1.Color = Color.Purple

Dim line2 As Trendline = chart.NSeries(3).TrendLines(2)

line2.DisplayEquation = True

line2.DisplayRSquared = True

line2.Color = Color.Teal

Dim line3 As Trendline = chart.NSeries(4).TrendLines(3)

line3.DisplayEquation = True

line3.DisplayRSquared = True

line3.Color = Color.Gold

Dim line4 As Trendline = chart.NSeries(5).TrendLines(4)

line4.DisplayEquation = True

line4.DisplayRSquared = True

line4.Color = Color.Blue


Please try other trendline type.



I want to display Line with markers displayed at each data.How can we do this.




I think trendline doesn’t display markers. I cannot set it in MS Excel.



I changed the code and it is working now.