2016-07-07 98 views
0

如何將數據從MySQL表格中拆分爲Google表格。將數據導入到來自mysql的Google表格中

for (var i = 0; i < 1; i++) { 
    while (result.next()) { 
    var rowData = []; 
    for (var column = 0; column < result.getMetaData().getColumnCount(); column++) { 
     rowData.push(result.getString(column + 1)); 
    } 
    data.push(rowData); 
    } 
    sheet.getRange(sheet.getLastRow() + 1, 1, data.length, data[0].length).setValues(data); 
} 

有沒有一種方法,我可以打破在2500個記錄的推動和有觸發趕上來,在2501和直到所有的表數據被推到張在5000破解等。

回答

1

使用屬性服務(https://developers.google.com/apps-script/reference/properties/)存儲您的迭代計數,然後讓腳本在從觸發器運行時引用它。

屬性存儲爲字符串,所以請記住轉換爲數字來執行計算。

//On script exit write the iteration count 
var scriptProperties = PropertiesService.getScriptProperties(); 
scriptProperties.setProperty('myCount', i); 

//when the script runs get the latest iteration count, and start at next 
var scriptProperties = PropertiesService.getScriptProperties(); 
var startNUmber = scriptProperties.getProperty('myCount').parseInt() + 1;