Skip to content

Instantly share code, notes, and snippets.

View chemiadel's full-sized avatar

Adel chemiadel

View GitHub Profile
@chemiadel
chemiadel / fetcher.ts
Created October 6, 2021 07:27
simple-gql-fetcher
const fetcher = async (query : string, variables?: any, headers?: any ) => await fetch(`/api/graphql`, {
method:'post',
headers: {
'Content-Type': 'application/json',
...headers
},
body: JSON.stringify({
query,
variables
})
//Here's sample with doGet
function doGet(e) {
//e is an Javascript object check it in GAS Guide to know its parameters
switch(e.parameter.functionName) {
case "Hello":
runHello()
break;
case "Cool":
runCool()
function importTable(URL,i) {
//Content
var resp=UrlFetchApp.fetch(URL).getContentText();
//Regex
var regT=/<table[^>]*>([\s\S]*?)<\/table[^>]*>/g;
var regR=/<tr[^>]*>([\s\S]*?)<\/tr[^>]*>/g;
var regC=/<t[^>]*>([\s\S]*?)<\/t[^>]*>/g;
//Get All Tables
//https://gist.github.com/chemiadel/f1314bf8403eda071ca10c584947d1e7
//Sheet Name
SHEET_NAME="Emails"
function sendEmails() {
//Assign Spreadsheet, Sheet to object variables
var ss=SpreadsheetApp.getActiveSpreadsheet();
var sheet=ss.getSheetByName(SHEET_NAME);
//https://gist.github.com/chemiadel/f2a023f2022ef6eafa86e7326bc92062
RANGE="B5:F10";
SHEET_NAME="Sheet1";
//Types available : pdf,csv or xlsx
EXPORT_TYPE="pdf";
function EmailRange() {
//Assign The Spreadsheet,Sheet,Range to variables
@chemiadel
chemiadel / ExportAndEmailCustomSheetsAsPDF.gs
Last active March 22, 2023 01:26
Script export and send email of custom sheet on PDF for Google Sheets with GAS
//https://gist.github.com/chemiadel/bee4cb03481b580275d5296a3e7adc0d
function EmailPDF() {
//Get Active Spreadsheet
var spreadSheet=SpreadsheetApp.getActiveSpreadsheet();
//Get All Sheets of the spreadsheets
var sheets=spreadSheet.getSheets();
//Sheet wanted to export on PDF
@chemiadel
chemiadel / exportSpreadsheet.gs
Created October 6, 2017 10:14 — forked from Spencer-Easton/exportSpreadsheet.gs
Example on how to export a Google sheet to various formats, includes most PDF options
function exportSpreadsheet() {
//All requests must include id in the path and a format parameter
//https://docs.google.com/spreadsheets/d/{SpreadsheetId}/export
//FORMATS WITH NO ADDITIONAL OPTIONS
//format=xlsx //excel
//format=ods //Open Document Spreadsheet
//format=zip //html zipped
@chemiadel
chemiadel / ReadPDF.vb
Created August 19, 2017 02:53 — forked from Phuseos/ReadPDF.vb
Select and read PDF files (VBA / MS Access)
sub ReadPDF()
'NOTE: Adobe Acrobat Pro XI or higher has to be installed and the following references have to be active:
'Adobe Acrobat 10.0 Type Library (acrobat.tlb) Usually found in: C:\Program Files (x86)\Adobe\Acrobat 11.0\Acrobat\
'Acrobat Access 3.0 Type Library (Accessibility.api) Usually found in: C:\Program Files (x86)\Adobe\Acrobat 11.0\Acrobat\plug_ins\
'To check for active references, see Tools -> References OR use the Immediate window (ctrl + G) and type "for each r in references : debug.Print r.name, r.fullpath : next r" (minus "" quotes)
Dim AcroApp As Acrobat.CAcroApp 'We're going to use the Acrobat 'app', so point to that
Dim theForm As Acrobat.CAcroPDDoc 'Define that we're going to use a Acrobat Form (known as PDF)