Last active
December 18, 2015 15:09
-
-
Save s2kw/5802465 to your computer and use it in GitHub Desktop.
Google Spreadsheet.
read / write test.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
App -> SpreadsheetFile -> aSheet -> Range -> Cell/Value | |
*/ | |
function readObject() { | |
objectPool = SpreadsheetApp.openById(read_sheet_id).getSheetByName('sheet1').getRange(1,1,20,20).getValues(); | |
} | |
function writeObject(){ | |
SpreadsheetApp.openById(write_sheet_id).getSheetByName('sheet3').getRange(1,1,20,20).setValues(objectPool); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
read_sheet_id = 'xx'; | |
write_sheet_id = 'yy'; | |
objectPool = {}; // not reauired. | |
function main(){ | |
var lockf = LockService.getPublicLock(); | |
if(lockf.hasLock()){ | |
Browser.msgBox("lock 済みです。だれかがスクリプトを実行中。"); | |
return; | |
} | |
try{ | |
lockf.waitLock(10000); | |
}catch(e){ | |
SpreadsheetApp.openById(read_sheet_id).getSheetByName('sheet1').getRange(21,i++).setValue("lock 失敗"); | |
Browser.msgBox(e); | |
return; | |
} | |
readObject(); | |
writeObject(); | |
lockf.releaseLock(); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
add lock sys.