问题描述:

I'm experimenting with Blockspring which provides a Google Sheets add-on which can, for example, run a function which returns data from a webservice e.g.

=BLOCKSPRING("get-stock-current-stats", "ticker", "MSFT")

I want to refresh a cell's data but don't see a 'refresh' call in the docs.

function onOpen() {

createTimeDrivenTriggers()

}

function createTimeDrivenTriggers() {

// Trigger every minute

ScriptApp.newTrigger('myFunction')

.timeBased()

.everyMinutes(1)

.create();

}

function myFunction() {

Logger.log('I ran'); // can see this in the logs

SpreadsheetApp.getActiveSheet().getRange('B4').getValue() //presumably returns a value to the script

}

网友答案:

Use the flush() method:

Google Documentation

SpreadsheetApp.flush();

Quote from documentation:

Applies all pending Spreadsheet changes

If there were no changes to the spreadsheet, but you want to force formulas recalculate, you will need to make a change, and then use SpreadsheetApp.flush();

For example, you could get the value from cell A1, then set the same value to cell A1. So, there is no chance of loosing data because you are getting and setting the same value. The change allows. SpreadsheetApp.flush(); to recalculate all the formulas.

网友答案:

Select the cell with the formula or multiple cells with formulas From the Google menu select: Add-ons > Blockspring > Refresh Selected Cells

Hope that helps

相关阅读:
Top