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

Radgrid Export to Excel Format xlsx : Cell Data Formatting issue

6 Answers 852 Views
Grid
This is a migrated thread and some comments may be shown as answers.
purna
Top achievements
Rank 1
purna asked on 26 Nov 2014, 10:17 AM
String not getting correctly, While exporting grid into excel. I am using "GridExcelExportFormat" is "Xlsx". Before exporting into excel the number string are showing correctly. But after exporting those numbers are automatically converted into date format. I am used "SuppressColumnDataFormatStrings" true/false, then also getting same issue. Please help me.

Grid column datatype is string.

6 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 28 Nov 2014, 03:38 PM
Hello Purna,

This works fine on my end. Please try the following setup and let me know if it behaves correctly at your side.
<telerik:RadGrid ID="RadGrid1" runat="server">
    <MasterTableView CommandItemDisplay="Top">
        <CommandItemSettings ShowExportToExcelButton="true" />
        <Columns>
            <telerik:GridBoundColumn DataField="col1" />
        </Columns>
    </MasterTableView>
    <ExportSettings>
        <Excel Format="Xlsx" />
    </ExportSettings>
</telerik:RadGrid>

void RadGrid1_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
    DataTable table = new DataTable();
    table.Columns.Add("col1");
    table.Columns.Add("col2");
    for (int i = 0; i < 10; i++)
    {
        table.Rows.Add("23:00-00:00", i);
    }
    RadGrid1.DataSource = table;
}

Regards,
Daniel
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
purna
Top achievements
Rank 1
answered on 02 Dec 2014, 10:29 AM
Hello Daniel,

Same issue repeated again with your code also. I am using "ASP.NET AJAX Q3 2014" version. PFA.

Please help in this issue.

Thanks & Regards,
Purna.
0
Daniel
Telerik team
answered on 05 Dec 2014, 12:42 PM
Hello Purna,

I suppose that the value might get parsed in a different way for your culture. In this case, you can force this column's cells to be in "text" format as demonstrated below:
protected void RadGrid1_InfrastructureExporting(object sender, GridInfrastructureExportingEventArgs e)
{
    foreach (Cell cell in e.ExportStructure.Tables[0].Columns[1].Cells)
    {
        cell.Format = "@";
    }
}

I hope this helps.

Regards,
Daniel
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
purna
Top achievements
Rank 1
answered on 10 Dec 2014, 03:45 PM
Hello Daniel,

Thanks for your response.

I applied cell format, as per suggestion. But i am not get success. 

PFA.

Please help me in this issue.

Thanks & Regards,
Purna.
0
purna
Top achievements
Rank 1
answered on 10 Dec 2014, 03:47 PM
Hello Daniel,

Thanks for your response.

I applied cell format, as per suggestion. But i am not get success. 

PFA.

Please help me in this issue.

Thanks & Regards,
Purna.
0
Daniel
Telerik team
answered on 15 Dec 2014, 12:30 PM
Hello Purna,

Please make sure that you have applied this format to the correct column. It might be column "2" in your case.

Regards,
Daniel
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
purna
Top achievements
Rank 1
Answers by
Daniel
Telerik team
purna
Top achievements
Rank 1
Share this question
or