losing Trailing zero from Amount field while printing in excel automation using report [nav 2009 R2]

Hi All,

 

Thanks In Advance,

i need help for amount print in excel

Like my amount field value is 120.20 but in excel its showing 120.2

I did below codes but it didn't work for me:

  1. TxtPreAmt :=FORMAT(PremAmt,7,'<precision,2><Integer Thousand><Decimals>');
  2. xlWorkSheet.Range('K'+ FORMAT(J)).Value :=FORMAT(PremAmt,0,'<Precision,2:2><Standard Format,0>');
  3. FORMAT(Round(PremAmt,0.01));
  4. FORMAT(PremAmt,0,'<Integer Thousand><Decimals,3>');
  5. FORMAT(PremAmt,0,'<Precision,2><sign><Integer Thousand><Decimals,3>');

in message box value coming properly but in excel trailing 0 is not showing please help

 

Thanks

  • Hi All,

    Just Got Solution By running Macro

    Sub Macro1()

    '

    ' Macro1 Macro

    '

    '

       ActiveCell.FormulaR1C1 = "120.2"

       Range("A2").Select

       Application.Goto Reference:="Macro1"

       Application.Run "Book1!Macro1"

       Selection.ClearContents

       Range("A1").Select

       Selection.NumberFormat = "0.00"

       Application.Goto Reference:="Macro1"

       Selection.Merge

       Range("F4").Select

       Selection.Merge

       Range("A3").Select

     

    So after reading this code i saw highlighted code line of above code

    so just added this line below to printing code line and issue resolved.


    xlWorkSheet.Range('d'+ FORMAT(J)).NumberFormat := '#,##0.00';  

     

     

    Thanks

  • When you print it excel like
    Addcolumn(Amount,'','',false,'#0,00.00',format::Number). This will automatically put the 120.20, you don't have to do any format or other functions.
Related