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

How to export an sql server 2008 r2 time(0) data type field to an excel file

1 Answer 76 Views
Grid
This is a migrated thread and some comments may be shown as answers.
George
Top achievements
Rank 1
George asked on 22 Sep 2011, 10:26 AM
Hello,

I have an sql server 2008 r2 time(0) data type field with format (hh:mm:ss) to a radgrid and i would like to export it to an excel file.

I use this code:

StyleElement timeStyle = new StyleElement("timeItemStyle");
timeStyle.NumberFormat.Attributes["ss:Format"] = "hh:mm:ss";
//timeStyle.NumberFormat.FormatType = NumberFormatType.LongTime;
timeStyle.FontStyle.Color = System.Drawing.Color.Red;
e.Styles.Add(timeStyle);
 
StyleElement alternatingTimeStyle = new StyleElement("alternatingTimeItemStyle");
alternatingTimeStyle.NumberFormat.Attributes["ss:Format"] = "hh:mm:ss";
//timeStyle.NumberFormat.FormatType = NumberFormatType.LongTime;
alternatingTimeStyle.FontStyle.Color = System.Drawing.Color.Red;
e.Styles.Add(alternatingTimeStyle);
 
but i can't see the time data at my excel file. Where is the error;

P.S.

The LongTime member of NumberFormatType enumerator is not suitable for my case, because my data are in hh:mm:ss format and not in hh:mm:ss:ff. 

Thank you very much.

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 22 Sep 2011, 11:02 AM
Hello George,

You can use mso-number-format to achieve this.
Word/Excel export (HTML-based) (Number formats / Formulas part)

Thanks,
Princy
Tags
Grid
Asked by
George
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or