After Numberformat in Excel get the value back to a variable

MGM08MGM08 Member Posts: 41
IF NOT(CREATE(xlApp)) THEN
ERROR('Error creating excel file');
xlWorkBook := xlApp.Workbooks.Add(-4167);
xlWorkSheet := xlApp.ActiveSheet;
xlWorkSheet.Name := 'Test Format';

xlWorkSheet.Range('A1').Value := FORMAT('1000000');
xlWorkSheet.Range('A1').Select;

xlWorkSheet.Cells.NumberFormat := '[>9999999]##\,##\,##\,##0.00;[>99999]##\,##\,##0.00;##,##0.00;General';

In excel this formats the cell to the indian format. it shows 10,00,000.00

How to retrieve the same to a global variable.


if i just assign back the cell value its giving 1,000,000.

Thanks.

Answers

  • MGM08MGM08 Member Posts: 41
    This bit of code solved my problem.

    IF NOT(CREATE(xlApp)) THEN
    ERROR('Error creating excel file');
    xlWorkBook := xlApp.Workbooks.Add(-4167);
    xlWorkSheet := xlApp.ActiveSheet;
    xlWorkSheet.Name := 'Test Format';

    amt := 1000000;

    Txt := '=text('+format(amt,STRLEN(format(amt)),1)+',"[>9999999]##\,##\,##\,##0.00;[>99999]##\,##\,##0.00;##,##0.00;General")';
    xlWorkSheet.Range('A1').Value := txt;


    Tet := xlWorkSheet.Range('A1').Value;

    xlWorkBook.close(false);
    MESSAGE('%1',Tet);
Sign In or Register to comment.