将Google表格转换为PDF?

时间:2019-07-18 20:39:24

标签: pdf google-apps-script google-sheets

我正在使用以下脚本将Google表格转换为pdf,然后将其保存到文件夹。我收到以下错误消息:service error: Drive。我怎样才能解决这个问题?该脚本可在某些计算机上运行,​​但不能在其他计算机上运行。

var destSpreadsheet = SpreadsheetApp.open(DriveApp.getFileById(sourceSpreadsheet.getId()).makeCopy("tmp_convert_to_pdf", folder))

这是发生错误的代码行。

var sheetname2="DO NOT TOUCH THIS TAB";
var sheetName = "Printout";
var folderID = "xxxxxxxxx"; // Folder id to save in a folder.


var sourceSpreadsheet = SpreadsheetApp.getActive();
var sourceSheet = sourceSpreadsheet.getSheetByName(sheetName);
var range=sourceSheet.getRange('A1:U283');
var data=range.getValues();
var printout2=sourceSpreadsheet.getSheetByName('DO NOT TOUCH THIS TAB');
printout2.getRange(1,1,283,21).setValues(data);
var dateofsheet=printout2.getRange('Q2').getValue();
var dateofsheet2=Utilities.formatDate(dateofsheet, "CST", "MMM d yyyy") ;
var pdfName = dateofsheet2;



var folder = DriveApp.getFolderById(folderID);

//Copy whole spreadsheet
var destSpreadsheet = SpreadsheetApp.open(DriveApp.getFileById        (sourceSpreadsheet.getId()).makeCopy("tmp_convert_to_pdf", folder))

0 个答案:

没有答案