Page 1 of 1
Exporting Date with Excel
Posted: Tue Sep 29, 2009 9:30 am
by 9533057
Hi,
Questions about exporting date with Teechart Pro 7.0:
If I export my Teechart chart data with
My date are not showing correct format

- export_excel.jpg (74.09 KiB) Viewed 11787 times
Now, If I export data with following code
My date are in correct format but when Excel is launching I've the following alert message:

- export_text.jpg (27.46 KiB) Viewed 11744 times

- export_excel_data.jpg (56.88 KiB) Viewed 11774 times
So, what is the best way to export to excel data whith date ?
Is Teechart Pro 8.0 displaying date correctly when exporting to excel ?
Thanks a lot for your help
Guilz
Re: Exporting Date with Excel
Posted: Tue Sep 29, 2009 11:29 am
by narcis
Hi Guilz,
The same problem and solution were described
here.
Re: Exporting Date with Excel
Posted: Tue Sep 29, 2009 12:55 pm
by 9533057
Narcís wrote:Hi Guilz,
The same problem and solution were described
here.
Thanks Narcis - I had already read this topic before posting...
I don't think we can speak about solution if we must reopen Excel file after each export and set each datetime column as datetime field instead of general field type
Guilz
Re: Exporting Date with Excel
Posted: Tue Sep 29, 2009 1:50 pm
by yeray
Hi Guilz,
I'm not getting any error with the following code in TeeChart AX v8 and Office 2003. Could you please try if it works fine for you?
Code: Select all
Private Sub Form_Load()
TChart1.Aspect.View3D = False
TChart1.AddSeries scLine
TChart1.Series(0).XValues.DateTime = True
Dim month, year, i As Integer
i = 0
For year = 2003 To 2009
For month = 1 To 12
TChart1.Series(0).AddXY DateValue("1/" & Str$(month) & "/" & Str$(year)), Sin(i / 10), "", clTeeColor
i = i + 1
Next month
Next year
TChart1.Export.asText.SaveToFile "C:\tmp\test.xls"
End Sub
Re: Exporting Date with Excel
Posted: Tue Sep 29, 2009 2:00 pm
by 9533057
Yeray,
I confirm - This Excel Messagebox appear only with Office 2007.
We don"t have this issue with previous version of Excel.
Regards,
Guilz
Re: Exporting Date with Excel
Posted: Thu Oct 01, 2009 9:29 am
by yeray
Hi Guilz,
Yes, I've verified that this error appears in office 2007.
So, as you've seen there are two possibilities:
- asXLS: works without any error at all. But, as Narcís explained, as delphi saves the numbers as doubles, you'll see doubles instead of dates in the first column. And then you can set this column to Date format in Excel.
- asText: gives a format error in Office 2007 but it still opens the file and displays all the columns as you had them in TeeChart as it saves the strings.
Re: Exporting Date with Excel
Posted: Thu Oct 01, 2009 9:48 am
by 9533057
Hi Yeray,
Right - both are not fantastic
I will try to use the second one and before opening the Excel file use excel.Application object and save it as true xls with DisplayMessage = false...Not cool to patch the
asText method because
asXLS method does not work...
Good idea to do something in Teechart v9 no ?
Regards,
Guilz
Re: Exporting Date with Excel
Posted: Fri Oct 02, 2009 9:45 am
by yeray
Hi Guilz,
Yes, I've added this to the wish list to be revised in future releases (TV52014461).
Re: Exporting Date with Excel
Posted: Fri Oct 02, 2009 10:30 am
by 9533057
Thanks a lot Yeray
Guilz