ExcelBuffer Currency formatting

samyegsamyeg Member Posts: 3
edited 2014-10-16 in NAV Three Tier
I'm new to NAV development and I have a function to export data from NAV to Excel, the problem is I cannot format the cells in currency format, this is an example of the code:
// Displays the field as Text.
ExcelBuf.AddColumn('$' + FORMAT(PurchLine."Direct Unit Cost"),FALSE,'',FALSE,FALSE,FALSE,'',ExcelBuf."Cell Type"::Text);

// and/or

// Displays the field as number but without the currency format ($)
ExcelBuf.AddColumn(PurchLine."Direct Unit Cost",FALSE,'',FALSE,FALSE,FALSE,'',ExcelBuf."Cell Type"::Number);

What is need is to display numbers as $10,000.00

Can someone help me please?



  • Options
    nav_developmentnav_development Member Posts: 21
    You can use ExcelBuf.NumberFormat

    ExcelBuf.AddColumn(PurchLine."Direct Unit Cost",FALSE,'',FALSE,FALSE,FALSE,'','$####.00');
  • Options
    samyegsamyeg Member Posts: 3
    Well, Thanks 'nav_development' for your reply.

    Unfortunately, I used the suggested solution but it didn't work for me, So I used something we used to have in .net Development, right click on "AddColumn" method and choose "Go to Definition", in the definition I found that 7th parameter is 'NumFormat', so i got the number format string form Excel and passed it as text format parameter of the method and it worked! =D>

    this is the code I used:
    //  $      10,000.00
    ExcelBuf.AddColumn(PurchLine."Direct Unit Cost",FALSE,'',FALSE,FALSE,FALSE,'_($* #,##0.00_)',ExcelBuf."Cell Type"::Number);
  • Options
    nav_developmentnav_development Member Posts: 21
    Ohh..thanks for posting feedback. it works well in my case. Which version are you using?
Sign In or Register to comment.