Search code examples
export-to-excelradgrid

Radgrid Export with currency value


I'm using radgrid to export to excel file. Everything is ok except one thing. I would like to format the value as currency style but when exporting done the style is Accounting

I catch the event

grid_ExcelExportCellFormatting(object source, ExcelExportCellFormattingEventArgs e)

and I handled in this as below

e.Cell.Style["mso-number-format"] = "Currency";

Please help!


[EDITED ON 28 June 2012] Following The links as Daniel Benitez provide. I solved this issue. And I have some experience from it.

Refer my personal article if you interest.


Solution

  • Microsoft's documentation on the Office HTML format is insufficient and vague. You can see it below: http://msdn.microsoft.com/en-us/library/aa155477%28office.10%29.aspx

    (There is a CHM file packed within the self-extracting archive which you may prefer to unpack manually)

    If this is not working for your scenario, you may use a custom number format that mimics the default Currency format. Some examples are available below:

    http://niallodoherty.com/post.cfm/basic-html-to-excel-formatting

    http://agoric.com/sources/software/htmltoExcel

    http://cosicimiento.blogspot.com/2008/11/styling-excel-cells-with-mso-number.html

    http://www.telerik.com/help/aspnet-ajax/grid-html-export.html

    Another thing you could try is a bit of reverse-engineering-like approach. Namely:

    • export the file and then open it in Excel
    • set Currency format to the top left cell in the sheet
    • save the file as HTML
    • open it in Notepad++ or alternative text editor and examine how MS Excel set this :)

    I hope this helps :)