Parse xml to Spreadsheet: log text is different by text cell

24 views
Skip to first unread message

Stefano

unread,
Nov 1, 2022, 5:47:17 AM11/1/22
to Google Apps Script Community
Hi,

I parse a file xml to Spreadsheet file, this is a part of code:

linee.forEach (item => {
  var linea = item.getChild('NumeroLinea').getText();
  var descrizione = item.getChild('Descrizione').getText();
  var quantita = item.getChild('Quantita').getText();
  var unita = item.getChild('UnitaMisura').getText();
  var prezzou = item.getChild('PrezzoUnitario').getText();
  var prezzot = item.getChild('PrezzoTotale').getText();
  var IVA = item.getChild('AliquotaIVA').getText();
  Logger.log('%s',linea);
  Logger.log('%s',descrizione);
  Logger.log('%s',quantita);
  Logger.log('%s',unita);
  Logger.log('%s',prezzou);
  Logger.log('%s',prezzot);
  Logger.log('%s',IVA);
  SpreadsheetApp.getActiveSheet().appendRow([anagrafica,date,linea,descrizione,quantita,unita,prezzou,prezzot,IVA]);

When I read LOG prezzou or prezzot are 1.09000000 and 19.62 but when I read  Spreadsheet are 150001.00.00   and 20.02. Why?
How could I solve it? Is it a bug?
Thanks!!

Stefano

unread,
Nov 1, 2022, 12:24:51 PM11/1/22
to Google Apps Script Community
I've solved.

Problem is that Appendrow set an automatic format. So before to pass it at Appendrow, I change my var in this way:
 var prezzou = item.getChild('PrezzoUnitario').getText().toString().replace(".",",");

So AppenRow read string, as an european number and format go right.
Reply all
Reply to author
Forward
0 new messages