Page 1 of 1

export datetime data to excel

Posted: Wed Apr 27, 2011 9:41 am
by 15658478
Hello,

We have a date time values on the bottom axis. Export to excel export only the date as string and the time is not saved at all.
We are usin .NET, version 4.1.2011.4192.

The exported file looks as follow:
<table border="1">
<tr><td>X</td><td>Y</td></tr>
<tr><td>27/04/2011</td><td>20</td></tr>
<tr><td>27/04/2011</td><td>30</td></tr>
<tr><td>27/04/2011</td><td>40</td></tr>
<tr><td>27/04/2011</td><td>50</td></tr>
<tr><td>27/04/2011</td><td>40</td></tr>
</table>
bellow code example that reproduce the problem

Code: Select all

        public Form1()
        {
            InitializeComponent();

            tChart1.Axes.Bottom.Labels.DateTimeFormat = "HH:mm:ss\n";
            tChart1.Axes.Bottom.Labels.MultiLine = false;
            tChart1.Aspect.View3D = false;
            tChart1.Aspect.ZOffset = 0;
            Steema.TeeChart.Styles.Line line = new Steema.TeeChart.Styles.Line();         
            
            line.XValues.DateTime = true;
            line.Pointer.Visible = true;
            line.LinePen.Width = 2;
            line.TreatNulls = TreatNullsStyle.DoNotPaint;

            tChart1.Series.Add(line);

            line.Add(DateTime.Now - new TimeSpan(5, 0, 0), 20);
            line.Add(DateTime.Now - new TimeSpan(4, 0, 0), 30);
            line.Add(DateTime.Now - new TimeSpan(3, 0, 0), 40);
            line.Add(DateTime.Now - new TimeSpan(2, 0, 0), 50);
            line.Add(DateTime.Now - new TimeSpan(1, 0, 0), 40);
                
        }
        
        private void button1_Click(object sender, EventArgs e)
        {
            tChart1.Export.Data.Excel.Series = null; // export all series
            tChart1.Export.Data.Excel.Save("Chart1.xls");        
        }


Re: export datetime data to excel

Posted: Wed Apr 27, 2011 12:01 pm
by 10050769
Hello alianak74,

I'm afraid this is not possible for now and it is added yet in wish-list with number (TF02014823) as explain in this thread.

Thanks,

Re: export datetime data to excel

Posted: Wed Apr 27, 2011 12:38 pm
by 15658478
Hi,

This is a BUG and not some new requirement, and it's different from the task TF02014823.
In TF02014823 user get a double for x-axis data. I wish to get a double value or any other with full information, but I get a string and format is different from axis format ( date only). So why this format???

You should give to this issue different priority!!

Re: export datetime data to excel

Posted: Wed Apr 27, 2011 2:27 pm
by 10050769
Hello alinak74,

I apologize, when I recommended you saw the solution of the link. I didn’t realize that the thread talked about XML and all the time I read xls, sorry my previous answer isn’t a solution for your problem.
So is allowed export all of date time in xls format, you only have change the format of DateTimeFormat before export date as do in next lines of code:

Code: Select all

     private void button1_Click(object sender, EventArgs e)    
        {
            tChart1[0].DateTimeFormat = "dd/mmm/yyyy hh:mm:ss";
            tChart1.Export.Data.Excel.Series = null; // export all series
            tChart1.Export.Data.Excel.Save(@"Chart1.xls");
        }
I hope will helps.
Thanks,

Re: export datetime data to excel

Posted: Thu Apr 28, 2011 7:22 am
by 15658478
Thanks Sandra, now it's ok!