简体   繁体   English

如何在谷歌应用脚本上使用 NumberFormat function

[英]How use a NumberFormat function on google apps script

I have a webapp that I get a value.我有一个获得价值的网络应用程序。 I make an append row with this data for my sheet.我用这些数据为我的工作表制作了一个 append 行。 However, I want that this data have a text format, because I want to get the value like I typed.但是,我希望这些数据具有文本格式,因为我想获得我输入的值。 Some problems happen with my sheet, like an "and" be recognized as a number.我的工作表出现了一些问题,例如“和”被识别为数字。 Ex: 2000e7 appears as: 2.00E + 10. I know that yhave a function to change the format.例如:2000e7 显示为:2.00E + 10。我知道你有一个 function 来更改格式。 NumberFormat (" ")

But I think that I'm not using it correctly.但我认为我没有正确使用它。

My code:我的代码:

  var ws=  ss.getSheetByName(flag);
  ws.appendRow([Entrada,Modelo,SN,Ocorrencia,Status,data,obs])

  var ss2 = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss2.getSheets()[0];
  var range = sheet.getRange("My Last row");

// Money format
range.setNumberFormat("@");
  

Sometimes the better way is to prepend the value with ' rather than using setNumberFormat有时更好的方法是在值前面加上'而不是使用setNumberFormat

Related有关的

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM