有:
我一直在寻找答案,似乎人们走的两条路是特定于脚本的,或者是制作一个重复的文档,而改用它。
我们的文档是我运营的生产部门的估算计算器,是关键时间戳的数据收集文档,它决定着我们的日程安排,成本核算和工作单。由于错误“服务超时:电子表格”,该故障越来越频繁地出现。每个估计值都是重复的,并且在运行将文档ID写入主文档的脚本之前不会与主文档绑定。当主文档出现故障时,重复的所有脚本将继续起作用,除非将ID写入主文档的脚本。由于数百个文档写入主文档,并且已部署给我们商店中的其他人使用,因此我很犹豫要替换它。如果那是唯一的选择,我会的。如果有帮助,这些脚本将粘贴在下面。如果您知道任何其他解决方法,那绝对是首选!
function increment() {
var c = SpreadsheetApp.getActive().getSheetByName('Part 1a').getRange('J3');
c.setValue(Number (c.getValue()) + 1)
}
function createTimeTrigger(){
var trigger = ScriptApp.newTrigger("pressdate")
.timeBased()
.everyHours(4)
.create()
}
function copyDoc(){
var drive=DriveApp.getFileById('1uxIlMemedJt6RRajQIv3Zdum6E4wnQGy1M8ovQCes0k')
drive.makeCopy();
}
function saveAsSpreadsheet(){
var ss = SpreadsheetApp.getActiveSpreadsheet();
var destFolder = DriveApp.getFolderById("1-9t066bQzo4rSiWMn2Lug5yTHBCuOKZ4");
var sheet = ss.getActiveSheet();
var c = SpreadsheetApp.getActive().getSheetByName('Part 1a').getRange('J3');
var number = c.getValue();
var d = SpreadsheetApp.getActive().getSheetByName('Part 1a').getRange('C2');
var desc = d.getValue();
DriveApp.getFileById(ss.getId()).makeCopy("D"+number+" "+desc, destFolder).getId();
}
function generatePdf() {
var originalSpreadsheet = SpreadsheetApp.getActive();
var sourcesheet = originalSpreadsheet.getSheetByName("Quote Letter");
var sourcerange = sourcesheet.getRange('A1:I32');
var sourcevalues = sourcerange.getValues();
var data = sourcesheet.getDataRange().getValues();
var c = SpreadsheetApp.getActive().getSheetByName('Quote Letter').getRange('C6');
var number = c.getValue();
var d = SpreadsheetApp.getActive().getSheetByName('Quote Letter').getRange('G5');
var customer = d.getValue();
var newSpreadsheet = SpreadsheetApp.create(number + customer);
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var projectname = SpreadsheetApp.getActiveSpreadsheet();
var sheet = sourcesheet.copyTo(newSpreadsheet);
var destrange = sheet.getRange('A1:I32');
destrange.setValues(sourcevalues);
newSpreadsheet.getSheetByName('Sheet1').activate();
newSpreadsheet.deleteActiveSheet();
var pdf = DriveApp.getFileById(newSpreadsheet.getId());
var theBlob = pdf.getBlob().getAs('application/pdf').setName(number +" " + customer+".pdf");
var folderID = "15czubt3kG5n1IyaGsSYhSCFesjK68gAJ";
var folder = DriveApp.getFolderById(folderID);
var newFile = folder.createFile(theBlob);
DriveApp.getFileById(newSpreadsheet.getId()).setTrashed(true);
}
function pdfandemail () {
var originalSpreadsheet = SpreadsheetApp.getActive();
var sourcesheet = originalSpreadsheet.getSheetByName("Quote Letter");
var sourcerange = sourcesheet.getRange('A1:I32');
var sourcevalues = sourcerange.getValues();
var data = sourcesheet.getDataRange().getValues();
var c = SpreadsheetApp.getActive().getSheetByName('Quote Letter').getRange('C6');
var number = c.getValue();
var d = SpreadsheetApp.getActive().getSheetByName('Quote Letter').getRange('G5');
var customer = d.getValue();
var sss = originalSpreadsheet.getSheetByName("Automated Emails");
var newSpreadsheet = SpreadsheetApp.create(number + customer);
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var projectname = SpreadsheetApp.getActiveSpreadsheet();
var sheet = sourcesheet.copyTo(newSpreadsheet);
var destrange = sheet.getRange('A1:I32');
destrange.setValues(sourcevalues);
newSpreadsheet.getSheetByName('Sheet1').activate();
newSpreadsheet.deleteActiveSheet();
var pdf = DriveApp.getFileById(newSpreadsheet.getId());
var theBlob = pdf.getBlob().getAs('application/pdf').setName(number +" " + customer+".pdf");
var folderID = "15czubt3kG5n1IyaGsSYhSCFesjK68gAJ";
var folder = DriveApp.getFolderById(folderID);
var newFile = folder.createFile(theBlob);
var fileID = newFile.getId();
DriveApp.getFileById(newSpreadsheet.getId()).setTrashed(true);
var emailaddress = sss.getRange('F3').getValue();
var subject = sourcesheet.getRange('G5:G6').getValues();
var message = ("Your quote is attached."+"\n"+"This is an automated message");
var attach = DriveApp.getFileById(fileID);
var blob = attach.getAs(MimeType.PDF);
MailApp.sendEmail(emailaddress, subject, message, {attachments:[blob]})
}
function jobTicket() {
var originalSpreadsheet = SpreadsheetApp.getActive();
var sourcesheet = originalSpreadsheet.getSheetByName("Job Ticket");
var sourcerange = sourcesheet.getRange('A1:K75');
var sourcevalues = sourcerange.getValues();
var data = sourcesheet.getDataRange().getValues();
var c = SpreadsheetApp.getActive().getSheetByName('Job Ticket').getRange('C2');
var number = c.getValue();
var d = SpreadsheetApp.getActive().getSheetByName('Quote Letter').getRange('G5');
var customer = d.getValue();
var newSpreadsheet = SpreadsheetApp.create(number + customer);
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var projectname = SpreadsheetApp.getActiveSpreadsheet();
var sheet = sourcesheet.copyTo(newSpreadsheet);
var destrange = sheet.getRange('A1:K75');
destrange.setValues(sourcevalues);
newSpreadsheet.getSheetByName('Sheet1').activate();
newSpreadsheet.deleteActiveSheet();
var pdf = DriveApp.getFileById(newSpreadsheet.getId());
var theBlob = pdf.getBlob().getAs('application/pdf').setName(number +" " + customer+".pdf");
var folderID = "1IO6yxOHg3zzejaSIMpn0EAIvGR3OWpqh";
var folder = DriveApp.getFolderById(folderID);
var newFile = folder.createFile(theBlob);
var ticketID = newFile.getId()
sourcesheet.getRange('J2').setValue(ticketID)
DriveApp.getFileById(newSpreadsheet.getId()).setTrashed(true);
}
function ClearCells() {
var sheet = SpreadsheetApp.getActive().getSheetByName('Part 1a');
sheet.getRange('J6:J19').clearContent();
sheet.getRange('L6:L8').clearContent();
sheet.getRange('R11:V20').clearContent();
sheet.getRange('B11:B16').clearContent();
sheet.getRange('L3').clearContent();
sheet.getRange('J29').clearContent();
sheet.getRange('L4').clearContent();
sheet.getRange('G13').clearContent();
sheet.getRange('G19').clearContent();
sheet.getRange('C7').setValue("1");
sheet.getRange('G18').setValue("2");
sheet.getRange('G11').setValue("13");
sheet.getRange('G12').setValue("19");
sheet.getRange('L16').clearContent();
sheet.getRange('L17').clearContent();
sheet.getRange('L19').clearContent();
sheet.getRange('K9').clearContent();
var sheet2 = SpreadsheetApp.getActive().getSheetByName('Part 2a');
sheet2.getRange('E15:H18').clearContent();
sheet2.getRange('C17:C19').clearContent();
sheet.getRange('R24').clearContent();
sheet.getRange('S24').clearContent();
sheet.getRange('T24').clearContent();
sheet.getRange('U24').clearContent();
sheet.getRange('S26').clearContent();
sheet.getRange('T26').clearContent();
sheet.getRange('R29').clearContent();
sheet.getRange('S29').clearContent();
sheet.getRange('T29').clearContent();
sheet.getRange('U29').clearContent();
sheet.getRange('S31').clearContent();
sheet.getRange('T31').clearContent();
sheet2.getRange('G13').clearContent();
sheet2.getRange('E20').setValue("=IF('Part 1a'!G19=TRUE,'Part 1a'!B11, \" \")");
sheet2.getRange('F20').setValue("=IF('Part 1a'!G19=TRUE,'Part 1a'!B12, \" \")");
sheet2.getRange('G20').setValue("=IF('Part 1a'!G19=TRUE,'Part 1a'!B13, \" \")");
sheet2.getRange('H20').setValue("=IF('Part 1a'!G19=TRUE,'Part 1a'!B14, \" \")");
sheet2.getRange('F22').setValue("=IF('Part 1a'!G19=TRUE,'Part 1a'!B15, \" \")");
sheet2.getRange('G22').setValue("=IF('Part 1a'!G19=TRUE,'Part 1a'!B16, \" \")");
sheet.getRange('B26').setValue("Use this field for Prep and Production notes. Notes inlcude Prep instructions, art location, gutters/impo/standing or new die info requirements for OSB, cartoning/kitting, mail notes, etc.");
sheet.getRange('B28').clearContent();
sheet.getRange('B30').setValue("Clearly describe OSB here. Foil, perfect bind, etc.");
sheet.getRange("M2").setValue("Indigo");
sheet2.getRange("H2").setValue("Indigo");
sheet2.getRange('C14').setValue("19");
sheet2.getRange('C15').setValue("13");
sheet.getRange('J23').setValue("='Indigo Engineeringa'!N18");
sheet.getRange('K23').setValue("='Indigo Engineeringa'!R2");
sheet.getRange('L23').setValue("='Indigo Engineeringa'!S2");
sheet.getRange('M23').setValue("='Indigo Engineeringa'!T2");
sheet.getRange('N23').setValue("='Indigo Engineeringa'!U2");
sheet.getRange('O23').setValue("='Indigo Engineeringa'!V2");
sheet2.getRange('F7').setValue("='Indigo Engineeringa'!N40");
sheet2.getRange('G7').setValue("='Indigo Engineeringa'!R27");
sheet2.getRange('H7').setValue("='Indigo Engineeringa'!T27");
sheet2.getRange('I7').setValue("='Indigo Engineeringa'!U27");
sheet2.getRange('J7').setValue("='Indigo Engineeringa'!S27");
sheet2.getRange('K7').setValue("='Indigo Engineeringa'!V27");
sheet.getRange('J24').setValue("=J22*(1+J23)");
sheet.getRange('K24').setValue("='Indigo Engineeringa'!R3");
sheet.getRange('L24').setValue("='Indigo Engineeringa'!S3");
sheet.getRange('M24').setValue("='Indigo Engineeringa'!T3");
sheet.getRange('N24').setValue("='Indigo Engineeringa'!U3");
sheet.getRange('O24').setValue("='Indigo Engineeringa'!V3");
sheet.getRange('C11').setValue("=IFERROR('Indigo Costsa'!B37, \" \")");
sheet.getRange('C12').setValue("=IFERROR('Indigo Costsa'!H37, \" \")");
sheet.getRange('C13').setValue("=IFERROR('Indigo Costsa'!N37, \" \")");
sheet.getRange('C14').setValue("=IFERROR('Indigo Costsa'!T37, \" \")");
sheet.getRange('C15').setValue("=IFERROR('Indigo Costsa'!Z37, \" \")");
sheet.getRange('C16').setValue("=IFERROR('Indigo Costsa'!AF37, \" \")");
sheet.getRange('R16').setValue("Outside Purchases:");
var engineering = SpreadsheetApp.getActive().getSheetByName('Indigo Engineeringa');
engineering.getRange('F6').setValue("=IF(AND(J8=TRUE,J9>3,J10=TRUE),(ROUNDDOWN((E18*2)/4,0))*4,IF(J8=TRUE,E12*2,E6*2))");
engineering.getRange('F30').setValue("=IF(AND(J32=TRUE,J33>3,J34=TRUE),(ROUNDDOWN((E42*2)/4,0))*4,IF(J32=TRUE,E36*2,E30*2))");
}
function record() {
var funcsource = SpreadsheetApp.openById('1AnphsilBFl1GQnTs2ja5Elcg7PbT5k7KI_tSTKZw8eI');
var funcsourcesheet = funcsource.getSheetByName('Job Schedule');
var source = SpreadsheetApp.getActiveSpreadsheet();
var id = source.getId();
funcsourcesheet.getRange('P2').setValue(id);
var target = SpreadsheetApp.openById('1AnphsilBFl1GQnTs2ja5Elcg7PbT5k7KI_tSTKZw8eI');
var targetsheet = target.getSheetByName('Records');
var rangeValues = funcsourcesheet.getRange('M2:02');
var A1Range = rangeValues.getA1Notation();
var SData = rangeValues.getValues()
var lr = targetsheet.getLastRow();
var lc = targetsheet.getLastColumn();
rangeValues.copyValuesToRange(targetsheet, 13, lc, (lr+1), (lr+1))
}
function digSchedule() {
var source = SpreadsheetApp.getActiveSpreadsheet();
var sourcesheet = source.getSheetByName('Job Schedule');
var target = SpreadsheetApp.getActiveSpreadsheet()
var targetsheet = target.getSheetByName('Records');
var rangeValues = sourcesheet.getRange('A2:O2');
var A1Range = rangeValues.getA1Notation();
var SData = rangeValues.getValues()
var lr = targetsheet.getLastRow();
var lc = targetsheet.getLastColumn();
var vS = target.getSheetByName('Job Ticket')
var vStartDate = vS.getRange("H11").getValue();
var vSTI = sourcesheet.getRange("L2").getValue();
var vEndDate = vS.getRange("H11").getValue();
var dur = sourcesheet.getRange("N2").getValue();
var vCust = vS.getRange("D3")
var vDesc = vS.getRange("D4")
var job = vS.getRange("C2")
var sales = source.getSheetByName("Automated Emails").getRange("F3").getValue();
var pm = source.getSheetByName("Automated Emails").getRange("F5").getValue();
var stat = vS.getRange("I11")
var po = vS.getRange("C11").getValue()
var pd = vS.getRange("H11").getValue()
var dd = vS.getRange("E11").getValue()
var note = vS.getRange("B8").getValue()
var ticket = vS.getRange('J2')
var calendar = CalendarApp.getCalendarById(
'midctt31euafr09grk7g5k4gbg@group.calendar.google.com');
var event = calendar.createEvent(stat.getValue()+" - " +job.getValue()+", "+ vCust.getValue()+", " +vDesc.getValue() ,
new Date(vStartDate),
new Date(vEndDate) )
event.setDescription(note + "\n" + " Proof Out: " +po + "\n" + " Print Date: " + pd + "\n" + " Due Date: " + dd + "\n" + " Duration: " + dur) ;
Logger.log('Event ID: ' + event.getId());
event.addGuest(sales)
var eID = event.getId();
vS.getRange("M2").setValue(eID);
}
var ss = SpreadsheetApp.getActive();
var protections = ss.getProtections(SpreadsheetApp.ProtectionType.RANGE);
for (var i = 0; i < protections.length; i++) {
var protection = protections[i];
if (protection.canEdit()) {
protection.remove();
}
}
function onOpen() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var menuEntries = []
menuEntries.push({name: "Trace Dependents", functionName: "traceDependents"});
ss.addMenu("Detective", menuEntries);
}
function pressdate() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var jt = ss.getSheetByName("Job Ticket");
var eid = jt.getRange("M2").getValue();
var cal = CalendarApp.getCalendarById('midctt31euafr09grk7g5k4gbg@group.calendar.google.com');
if(cal) {var calID = cal.getId();}
if(!cal) {
var cal = CalendarApp.getCalendarsByName("Digital") [0];
var calID = cal
}
var events = cal.getEventById(eid);
var eventDetails = [];
for(var i = 0; i<events.length; i++){
eventDetails.push([events[i].getStartTime(), events[i].getTitle(), events[i].getDescription(), events[i].getLocation()]);
}
var startRow = 11;
var startCol = 8;
for(var j = 0; j<eventDetails.length; j++){
var tempRange = sheet.getRange(startRow+j, startCol, 1, 4);
var eventArray = new Array(eventDetails[j]);
tempRange.setValues(eventArray);
}
var sd = events.getStartTime();
jt.getRange("h11").setValue(sd)
return eventDetails;
}
function traceDependents(){
var dependents = []
var ss = SpreadsheetApp.getActiveSpreadsheet();
var currentCell = ss.getActiveCell();
var currentCellRef = currentCell.getA1Notation();
var range = ss.getDataRange();
var regex = new RegExp("\\b" + currentCellRef + "\\b");
var formulas = range.getFormulas();
for (var i = 0; i < formulas.length; i++){
var row = formulas[i];
for (var j = 0; j < row.length; j++){
var cellFormula = row[j].replace(/\$/g, "");
if (regex.test(cellFormula)){
dependents.push([i,j]);
}
}
}
var dependentRefs = [];
for (var k = 0; k < dependents.length; k ++){
var rowNum = dependents[k][0] + 1;
var colNum = dependents[k][1] + 1;
var cell = range.getCell(rowNum, colNum);
var cellRef = cell.getA1Notation();
dependentRefs.push(cellRef);
}
var output = "Dependents: ";
if(dependentRefs.length > 0){
output += dependentRefs.join(", ");
} else {
output += " None";
}
currentCell.setNote(output);
}