Exporting Date with Excel

TeeChart for ActiveX, COM and ASP
Post Reply
Guilz
Newbie
Newbie
Posts: 46
Joined: Mon Nov 13, 2006 12:00 am

Exporting Date with Excel

Post by Guilz » Tue Sep 29, 2009 9:30 am

Hi,

Questions about exporting date with Teechart Pro 7.0:
If I export my Teechart chart data with

Code: Select all

.Export.asXLS
My date are not showing correct format
export_excel.jpg
export_excel.jpg (74.09 KiB) Viewed 11257 times
Now, If I export data with following code

Code: Select all

.Export.asText
My date are in correct format but when Excel is launching I've the following alert message:
export_text.jpg
export_text.jpg (27.46 KiB) Viewed 11214 times
export_excel_data.jpg
export_excel_data.jpg (56.88 KiB) Viewed 11244 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

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: Exporting Date with Excel

Post by Narcís » Tue Sep 29, 2009 11:29 am

Hi Guilz,

The same problem and solution were described here.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Guilz
Newbie
Newbie
Posts: 46
Joined: Mon Nov 13, 2006 12:00 am

Re: Exporting Date with Excel

Post by Guilz » Tue Sep 29, 2009 12:55 pm

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

Yeray
Site Admin
Site Admin
Posts: 9602
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Exporting Date with Excel

Post by Yeray » Tue Sep 29, 2009 1:50 pm

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
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Guilz
Newbie
Newbie
Posts: 46
Joined: Mon Nov 13, 2006 12:00 am

Re: Exporting Date with Excel

Post by Guilz » Tue Sep 29, 2009 2:00 pm

Yeray,

I confirm - This Excel Messagebox appear only with Office 2007.
We don"t have this issue with previous version of Excel.

Regards,

Guilz

Yeray
Site Admin
Site Admin
Posts: 9602
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Exporting Date with Excel

Post by Yeray » Thu Oct 01, 2009 9:29 am

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.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Guilz
Newbie
Newbie
Posts: 46
Joined: Mon Nov 13, 2006 12:00 am

Re: Exporting Date with Excel

Post by Guilz » Thu Oct 01, 2009 9:48 am

Hi Yeray,

Right - both are not fantastic :twisted:
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 ? :wink:

Regards,

Guilz

Yeray
Site Admin
Site Admin
Posts: 9602
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Exporting Date with Excel

Post by Yeray » Fri Oct 02, 2009 9:45 am

Hi Guilz,

Yes, I've added this to the wish list to be revised in future releases (TV52014461).
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Guilz
Newbie
Newbie
Posts: 46
Joined: Mon Nov 13, 2006 12:00 am

Re: Exporting Date with Excel

Post by Guilz » Fri Oct 02, 2009 10:30 am

Thanks a lot Yeray :D

Guilz

Post Reply