Skip to content

Instantly share code, notes, and snippets.

@tanaikech
tanaikech / submit.md
Last active July 26, 2023 16:13
Creating Spreadsheet with Custom Header and Footer using Google Apps Script

Creating Spreadsheet with Custom Header and Footer using Google Apps Script

In order to print and export as PDF file, this is a sample script for converting Spreadsheet to Spreadsheet which has the custom header and footer.

In this sample script, DocsServiceApp, which is Google Apps Script library, is used. And, in this case, the Spreadsheet with the custom header and footer is created as new Spreadsheet.

Before you use this script, please install DocsServiceApp and enable Drive API at Advanced Google services.

Sample script:

@Jasonhowling
Jasonhowling / SendPDFReport.js
Last active December 8, 2020 06:32
Google Apps Script to email a single sheet as PDF
// Google Apps Script to email a single sheet as PDF
// Primary Function SendReportPDF = Generate and send PDF from a single Google sheet. Build the email body, recipiant list & subject.
// Secondary = Add the Primary function to the Google Sheets Menu.
//----------------------------------------------------------------------------------------\\
// Secondary
// Add a menu option in the Google Sheets GUID called "Reports" with a submenu item called "Send Status"
// When you click on "Send Status" it will run the Primary function SendReportPDF
function onOpen(e) {
@lucashaley
lucashaley / SheetsGeneratePDF.gs
Created June 23, 2019 23:27
Google Sheets code to PDF generation
// Simple function to send Weekly Status Sheets to contacts listed on the "Contacts" sheet in the MPD.
// Load a menu item called "Project Admin" with a submenu item called "Send Status"
// Running this, sends the currently open sheet, as a PDF attachment
function onOpen() {
var submenu = [{name:"Email Lecture Form", functionName:"createLecturePDF"}];
SpreadsheetApp.getActiveSpreadsheet().addMenu('Project Admin', submenu);
}
function createLecturePDF() {
@primaryobjects
primaryobjects / Code.gs
Last active January 16, 2023 16:48
Export a Google Drive spreadsheet to PDF in Google Drive in the same folder.
// Simple function to add a menu option to the spreadsheet "Export", for saving a PDF of the spreadsheet directly to Google Drive.
// The exported file will be named: SheetName and saved in the same folder as the spreadsheet.
// To change the filename, just set pdfName inside generatePdf() to something else.
// Running this, sends the currently open sheet, as a PDF attachment
function onOpen() {
var submenu = [{name:"Save PDF", functionName:"generatePdf"}];
SpreadsheetApp.getActiveSpreadsheet().addMenu('Export', submenu);
}