Christian Rios
Christian Rios

Reputation: 477

Devexpress ASPxGridViewExporter will not export leading zeros

Is there a property I need to set for it to export this number with leading zeroes to excel? or Perhaps a setting on the grid itself? Something to force it to be treated as a string instead of guessing is a number?

I am using the latest version of Devexpress.

Upvotes: 1

Views: 3495

Answers (1)

Filip
Filip

Reputation: 3347

Use ASPxGridViewExporter.RenderBrickEvent to format exported values.

<dx:ASPxGridViewExporter ID="gridExport" runat="server" GridViewID="grid" OnRenderBrick="grid_OnRenderBrickEvent"/>
protected void grid_OnRenderBrickEvent(object sender, ASPxGridViewExportRenderingEventArgs e)
{
    if (e.RowType == GridViewRowType.Data && e.Column.FieldName == "yourcolumnfieldname")
    {
        string format = "0000000000.##";
        e.Text = ((decimal)e.Value).ToString(format);
        e.TextValue = ((decimal)e.Value).ToString(format);
}

Upvotes: 2

Related Questions