Reputation: 145
Can anyone help me out with how can I read Series Data ( X, Y and Series Naane) In Teechart from excel. I tried with CSeriesTextSource to read a Data.xls file but was not successful.
Thanks Akshay
Upvotes: 0
Views: 381
Reputation: 5039
You can create a csv from your xls and then import this csv with CSeriesTextSource
as in the example published here.
EDIT: Here it is the code from that post:
Private Sub Form_Load()
TChart1.Aspect.View3D = False
TChart1.Axis.Bottom.Labels.Style = 2 'talValue
TChart1.Axis.Left.Logarithmic = True
TChart1.AddSeries scFastLine
TChart1.AddSeries scFastLine
TChart1.AddSeries scPoint
TChart1.AddSeries scPoint
TChart1.Series(0).XValues.DateTime = True
TChart1.Series(1).XValues.DateTime = True
TChart1.Series(2).XValues.DateTime = True
TChart1.Series(3).XValues.DateTime = True
With SeriesTextSource1
.FileName = "C:\tmp\Data.csv"
.HeaderLines = 1
.FieldSeparator = ";"
.Series = TChart1.Series(0)
.AddField "X", 1
.AddField "Y", 2
.Active = True
.Series = TChart1.Series(1)
.AddField "X", 3
.AddField "Y", 4
.Active = True
' This works with v2012, but with v8
' .Series = TChart1.Series(2)
' .AddField "X", 5
' .AddField "Y", 6
' .Active = True
'
' .Series = TChart1.Series(3)
' .AddField "X", 7
' .AddField "Y", 8
' .Active = True
End With
' I add the values manually in v8:
TChart1.Series(2).AddXY CDate("10/11/2003"), 0, "", clTeeColor
TChart1.Series(3).AddXY CDate("01/02/1999"), 231.48, "", clTeeColor
End Sub
Private Sub TChart1_OnClick()
Caption = "Min: " + FormatDateTime(TChart1.Axis.Bottom.MinVisibleSeriesValue(True, 0)) + ", Max: " + FormatDateTime(TChart1.Axis.Bottom.MaxVisibleSeriesValue(True, 0))
End Sub
You can download the csv with the data for testing here.
Upvotes: 1