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

Why time format of some rows in excel are different from others

4 Answers 114 Views
Grid
This is a migrated thread and some comments may be shown as answers.
york
Top achievements
Rank 1
york asked on 05 Nov 2011, 09:41 PM
Hi,
I try to export radgrid to excel with RadGrid1.MasterTableView.ExportToExcel(). I am using MS office 2010.There is a weird thing in excel file. The time format of some rows are AM/PM and others are not (24 hours). In the radgrid, all rows are AM/PM format and are displayed correctly. But why in the exported excel file, some rows are not AM/PM? Thanks.

4 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 07 Nov 2011, 05:18 AM
Hello York,

Try setting the DataFormatString as shown below.
aspx:
<telerik:GridBoundColumn  DataFormatString="{0:yyyy-MM-dd hh:mm tt}" UniqueName="BirthDate" HeaderText="BirthDate" DataField="BirthDate">
</telerik:GridBoundColumn>

Thanks,
Shinu.
0
york
Top achievements
Rank 1
answered on 20 Dec 2011, 11:51 PM
Hi Shinu,

The DataFormatString is correct. But the strange thing I just notice is that, in the exported excel file, date from 1 to 12 is of format of AM/PM, while date from 13 to 30/31 is of format of 24 hours. Can you explain it? Thanks.

York
0
Accepted
Shinu
Top achievements
Rank 2
answered on 21 Dec 2011, 07:08 AM
Hello York,

I cannot reproduce the issue at my end. The above code worked as expected in my end. Also please try setting mso-number format as explained in this documentation.
Word/Excel export (HTML-based).

-Shinu.
0
york
Top achievements
Rank 1
answered on 21 Dec 2011, 07:59 AM
Thanks a lot, Shinu, mso-number-format is working. What is the hell of mso-number-format?
Tags
Grid
Asked by
york
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
york
Top achievements
Rank 1
Share this question
or