通过Apps脚本强制进行公式刷新 [英] Force formula refresh through Apps Script

查看:111
本文介绍了通过Apps脚本强制进行公式刷新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有时,当更改单元格的值时,公式不会在电子表格中自动刷新,并且单元格上显示注释以选择单元格,然后按CTRL + SHIFT + E以强制重新加载公式

Sometime, when changing the value of a cell, a formula is not refreshed automatically in a spreadsheet and a comment appears on the cell to select the cell and press CTRL+SHIFT+E to force the reload of the formula

我想从Apps脚本调用此重载功能。有没有办法用Apps Script来做到这一点?我尝试过Spreadsheet.flush(),但它不起作用。

I want to call this reload function from Apps Script. Is there a way to do it with Apps Script ? I tried Spreadsheet.flush(), but it's not working.

感谢您的帮助,
最好的祝愿

Thanks for help, Best regards

推荐答案

也许这个不可能的答案随新的电子表格或2012年以来的其他时间发生了变化。

Perhaps this "not possible" answer has changed with new Spreadsheets or at some other time since 2012.

如果你存储单元格的公式,清除单元格,然后设置单元格的公式,它似乎重新评估对我来说很好。

If you store the cell's formula, clear the cell, and then set the cell's formula, it seems to reevaluate just fine for me.

这是一个快速和肮脏的概述, m:

Here's a quick and dirty overview of what I'm doing:

// highlight a single cell and run this function
function myFunction() {
  var curr_cell = SpreadsheetApp.getActiveRange();
  var formula = curr_cell.getFormula();
  // clear only the contents, not notes or comments or formatting.
  curr_cell.clearContents();
  curr_cell.setFormula(formula);
}

这篇关于通过Apps脚本强制进行公式刷新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆