This is a migrated thread and some comments may be shown as answers.

Converting String Column into Date format while Exporting to CSV

3 Answers 351 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sachin Agrawal
Top achievements
Rank 1
Sachin Agrawal asked on 13 Dec 2011, 02:34 PM
Dear Telerik Team,

We are facing an issue while exporting grid data to CSV. Attached are snapshot of our issue. We have two columns for '# of FTEs' and '# of 'Freelancers' which contains values like 1-5, 5-10 and so on. This is shown in the attached file Grid.JPG.
But while expoting these data to CSV, they are converting to date format. It is showing in the attached file Excel.JPG.
Both of these column are having string datatype.

Please suggest solution for this issue.

We look forward to hearing.

Thanks,
Tarika Team

3 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 14 Dec 2011, 06:41 AM
Hi,

Microsoft Excel parses the cell values automatically depending on the local settings. For example the string 19/05 might change to 19.May automatically. The only workaround would be to insert a sign of equality (=) before the relevant string. For example: "012" should be modified as ="012".
CSV export help topic

Regards,
Daniel
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Jes
Top achievements
Rank 1
answered on 03 Aug 2012, 09:31 PM
How can this be done programmatically?  I'm using an older version so I don't have the GridExporting event that seems to be used to do this.  Is there another way?
0
Daniel
Telerik team
answered on 08 Aug 2012, 01:30 PM
Hello Jes,

You could try to insert the equality sign on ItemDataBound event as shown below:
bool isExport = false;
protected void Button1_Click(object sender, EventArgs e)
{
    isExport = true;
    RadGrid1.MasterTableView.ExportToCSV();
}
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
    if (e.Item is GridDataItem && isExport)
    {
          .... //add = here
    }
}

Let me know whether this helps.

Best regards,
Daniel
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Sachin Agrawal
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Jes
Top achievements
Rank 1
Share this question
or