Export Excel with currency format

2 Answers 508 Views
Grid
Fabio
Top achievements
Rank 1
Iron
Iron
Fabio asked on 07 Jun 2022, 07:32 PM
Hello,
I have a column in currency format and in the Grid presentation it shows right, for example: 200.00, but when exporting to excel it shows 200. What can I do to solve this problem?

2 Answers, 1 is accepted

Sort by
0
Mukesh
Top achievements
Rank 1
Iron
answered on 10 Jun 2022, 07:09 AM

Hello Fabio,

Please use below GRID event:

protected void RadGrid1_ExportCellFormatting(object sender, Telerik.Web.UI.ExportCellFormattingEventArgs e)
{
        if (e.FormattedColumn.ColumnType.IndexOf(GridCurrencyColumnName) > -1)
        {
            e.Cell.Style["mso-number-format"] = @"$0.00\;($0.00)"; // Appy your currency format here
        }
       // OR
        if (e.FormattedColumn.UniqueName == "GridCurrencyColumnName")
        {
           e.Cell.Style["mso-number-format"] = @"$0.00\;($0.00)";
        }
}

Thanks,

Mukesh Prajapati

0
Had
Top achievements
Rank 1
Iron
answered on 10 Jun 2022, 07:46 AM

You can declare the format directly from the radgrid table datacolumn

<telerik:GridNumericColumn DataFormatString="{0:$###,##0.00}" DataField="BilledAmt" DataType="System.Decimal" NumericType="Currency" HeaderText="BilledAmt">

 

OR  another way

can also try in ItemDataBound, you can declare the format

if (e.Item is GridDataItem) { GridDataItem sampleTable = (GridDataItem)e.Item;

//the format here refer to above format. }

Tags
Grid
Asked by
Fabio
Top achievements
Rank 1
Iron
Iron
Answers by
Mukesh
Top achievements
Rank 1
Iron
Had
Top achievements
Rank 1
Iron
Share this question
or