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

custom number format with ExcelML export

2 Answers 56 Views
Grid
This is a migrated thread and some comments may be shown as answers.
nabilus
Top achievements
Rank 1
nabilus asked on 21 Sep 2010, 06:23 PM
Hi.

I'm trying to get a 1 digit decimal format (ex: 102.4 or 6.0) instead of getting 2 digits (102.41 or 6.02).

protected void gridReport_ExcelMLExportStylesCreated(object source, GridExportExcelMLStyleCreatedArgs e)
        {
            StyleElement oneDecimalStyle = new StyleElement("oneDecimalStyle");
            oneDecimalStyle.NumberFormat.FormatType = NumberFormatType.Fixed;
            oneDecimalStyle.NumberFormat.Attributes["ss:Format"] = "0/.0";
            e.Styles.Add(oneDecimalStyle);
 }
  
protected void gridReport_ExcelMLExportRowCreated(object source, GridExportExcelMLRowCreatedArgs e)
        {
            if (e.RowType == GridExportExcelMLRowType.DataRow)
            {
                CellElement cell = e.Row.Cells.GetCellByName("airDuration");
                cell.StyleValue = "oneDecimalStyle";
             }
        }

What's wrong in my code?

2 Answers, 1 is accepted

Sort by
0
Accepted
Daniel
Telerik team
answered on 21 Sep 2010, 08:21 PM
Hello Andre,

Please set the number format to General
oneDecimalStyle.NumberFormat.FormatType = NumberFormatType.General;

and then modify your custom format this way:
oneDecimalStyle.NumberFormat.Attributes["ss:Format"] = "0.0";

Let me know whether this works as expected.

Best regards,
Daniel
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
nabilus
Top achievements
Rank 1
answered on 22 Sep 2010, 07:06 PM
Yes Thanks!
Tags
Grid
Asked by
nabilus
Top achievements
Rank 1
Answers by
Daniel
Telerik team
nabilus
Top achievements
Rank 1
Share this question
or