-1
在更改工作表時觸發此功能。將Google工作表導出爲公司網絡驅動器
function exportAsxlsx() {
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
var spreadsheetId = spreadsheet.getId()
var file = Drive.Files.get(spreadsheetId);
var url = file.exportLinks[MimeType.MICROSOFT_EXCEL];
var token = ScriptApp.getOAuthToken();
var response = UrlFetchApp.fetch(url, {
headers: {
'Authorization': 'Bearer ' + token
}
});
var blobs = response.getBlob();
var folder = DriveApp.getFoldersByName('\\GBC1234.fs1.util.xxint.com\Shared\Projects\Test_Google2Excel');
if(folder.hasNext()) {
var existingPlan1 = DriveApp.getFilesByName('TestGoogle2Excel.xlsx');
if(existingPlan1.hasNext()){
var existingPlan2 = existingPlan1.next();
var existingPlanID = existingPlan2.getId();
Drive.Files.remove(existingPlanID);
}
} else {
folder = DriveApp.createFolder('\\GBC1234.fs1.util.xxint.com\Shared\Projects\Test_Google2Excel');
}
folder = DriveApp.getFoldersByName('\\GBC1234.fs1.util.xxint.com\Shared\Projects\Test_Google2Excel').next();
folder.createFile(blobs).setName('TestGoogle2Excel.xlsx')
}
會發生什麼事是,它使目錄「\ GBC1234.fs1.util.xxint.com \共享\項目\ Test_Google2Excel」在谷歌驅動器,然後將文件保存在那裏。
我怎樣才能保存到我們公司的驅動器?
Google Apps腳本無法將文件保存到「公司驅動器」。你應該使用別的東西。 –