0

对不起,我认为这个问题对你来说很简单。

在 google 电子表格中,该值只能是数字(例如 1 或 245 或 100,234 )而不是文本。

我该怎么做这个控制?不是通过公式,而是通过代码。

我在尝试

var ss =  SpreadsheetApp.getActiveSpreadsheet()
var nomefoglio = ss.getSheetName()
var cellaattiva =ss.getActiveRange()
var valore =cellaattiva.getValue()

if (valore ?????? ) {
   cellaattiva.clear({contentsOnly:true}) 
   Browser.msgBox("value not admitted")
  }     

我的问题是关于要放置什么命令??????

谢谢

4

2 回答 2

0

您可以尝试以下方法:

function onEdit(e) {
  if (!isNumeric(e.value)) {
    e.range.clear({contentsOnly:true});
    Browser.msgBox('value not admitted');
  }
}

function isNumeric(value) {
  return !isNaN(parseFloat(value)) && isFinite(value);
}
于 2013-10-24T20:09:27.433 回答
0

谢谢它走了!你知道函数列表在哪里,如 isNumeric、isNaN ecc。使用白色或空值?

于 2013-10-28T16:00:37.477 回答