我正在尝试搜索一系列单元格,我已经设置了用于过滤的公式。我正在尝试setFormula根据单元格匹配的值来确定单元格可以具有和使用的三个不同值。到目前为止,她是我想出的。它适用于前两个公式,但如果两个单元格都包含数据,则不会设置“公式 3”。
function setFormulas(){
var ss = SpreadsheetApp.getActive()
var sheet = SpreadsheetApp.getActiveSheet()
var cell = ss.getActiveCell()
var cell1 = ("C2");
var formulaCell = ("A5");
var cell2 = ("C3");
var cell1isblank = SpreadsheetApp.getActiveSheet().getRange(cell1).isBlank()
var cell2isblank = SpreadsheetApp.getActiveSheet().getRange(cell2).isBlank()
if (cell1 == "0" ) {
SpreadsheetApp.getActiveSheet().getRange(formulaCell).setFormula("formula1")
}
else if (cell2 == "0" ) {
2SpreadsheetApp.getActiveSheet().getRange(formulaCell).setFormula("formula2")
}
}
else {
SpreadsheetApp.getActiveSheet().getRange(formulaCell).setFormula("Formula3")
}
Run Code Online (Sandbox Code Playgroud) 请考虑以下我的代码示例代码段.我试过没有运气的parseInt.在这里,我希望javascript在单元格中设置一个数字,PICweight然后在以后检索它并将其放在不同的单元格中totalcabin.你可以看到这里,我想设置的号码作为1,但代码运行时,它会返回NaN在totalcabin.
<td id="PICweight" type="tel"></td>
<script>
window.onchange = function setfields() {
document.getElementById("PICweight").innerHTML = 1;
var PICweight = document.getElementById("PICweight").value;
var totalcabin = document.getElementById("totalcabin");
totalcabin.innerHTML = +PICweight
}
</script>
Run Code Online (Sandbox Code Playgroud)