Google表格应用脚本Range.setValues
函数的行为似乎与要修改的单元格的数字格式有关:
false
强制为字符串"false"
。我最喜欢的是一种明智的行为,类似于Google Sheets API v4,在这里您可以force it to interpret values as raw.
我要寻找的是明确的行为,其中使用javascript
""
保持字符串不变。1.23
留下的数字。true
保持布尔值。Date(...)
停留的日期。有人知道这样的事情是否可能吗?
答案 0 :(得分:0)
当您使用 Format-> Number-> Automatic 时,有一种解决方法。
function sanitizeData(data) {
return data.map(function(row) {
return row.map(function(value) {
return typeof value === 'string' ? "'" + value : value;
});
});
}
如果数字格式明确设置为纯文本,则此操作将失败。但是,您可以使用clear(options)
method清除格式。