Google Apps Script > Excel

用來複製 Excel Sheet 的 function

function copy_sheet(source_excel_id,target_excel_id){
  
  //Source set  參考://https://developers.google.com/apps-script/reference/spreadsheet/spreadsheet-app
  
  var ss = SpreadsheetApp.openById(source_excel_id);
  Logger.log(ss.getName());
  
  //set target sheet by .getSheet 參考:https://developers.google.com/apps-script/reference/spreadsheet/sheet#copyTo(Spreadsheet)
  var sheet = ss.getSheets()[0];
  
  var destination = SpreadsheetApp.openById(target_excel_id); //目標 Excel 檔案
  sheet.copyTo(destination); //將來源檔案中指定的 Sheet 複製到目標 Excel 檔案裡面(會出現在最前面)
  
}

function go(){
  copy_sheet("來源 Excel ID","目標 Excel ID");
};

//最後直接執行 go(); 看結果有沒有複製第一個 Sheet 到目標 Excel 檔案。有就成功。

目前完成的應用

最終更新:2013年11月28日 01:56