Skip to content

Commit

Permalink
Simple replacer working with readme example
Browse files Browse the repository at this point in the history
  • Loading branch information
matheusmr13 committed Jun 19, 2016
1 parent a90d244 commit dc74b71
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,10 @@
Google App Script Templater to create documents and spreadsheets with simple JSON

SpreadSheet Sample: https://docs.google.com/spreadsheets/d/1l7sMxfD-qh4sbeu6Ax0z6v84YdahXDTG8hlPcE_vkEo/edit?usp=sharing

Google App Script last deployed url https://script.google.com/macros/s/AKfycbxF-s25Ceg0v1i9ZqRimDBDJi2gWMCfQSjKAc1cmlWx3_e1G7py/exec


TO USE WITH EXAMPLE: https://script.google.com/macros/s/AKfycbxF-s25Ceg0v1i9ZqRimDBDJi2gWMCfQSjKAc1cmlWx3_e1G7py/exec?header_title=my_cool_header_title
the url will return an ID, just use this id at
https://docs.google.com/spreadsheets/d/<MY_ID>/edit#gid=0
11 changes: 5 additions & 6 deletions SheetsTemplater.gs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function mock() {
};

function getTemplateIdByPaymentType (paymentType) {
return {'Cheque Pré-Datado' : '1TM7lRN_HOsfYEvGazw3cvPD7D4Xy8YQTCtDRfYH53d0'}[paymentType];
return '1l7sMxfD-qh4sbeu6Ax0z6v84YdahXDTG8hlPcE_vkEo';
};

function getSheetNewDocument (json) {
Expand All @@ -58,6 +58,7 @@ function isForEach(text) {
};

function processForEach (properties) {
return;
var sheet = properties.sheet;
var lineToRemove = properties.i;
var initialColumn = properties.j;
Expand Down Expand Up @@ -104,7 +105,7 @@ function processForEach (properties) {
};

function replaceValue(sheet, row, col, json, command) {
sheet.getRange(row, col).setValue(json[command.substring(1, command.length - 1)] || '');
sheet.getRange(row, col).setValue(json[command.split('.')[1].substring(0, command.split('.')[1].length - 1)] || '');
};

function processCell (properties) {
Expand All @@ -118,10 +119,8 @@ function processCell (properties) {
};

function doGet(e) {
var json = mock();
// if (e.parameters.checkingSystem != "COINFO_PAXPRO")
// return;
// var json = e ? e.parameters : {};
var json = e ? e.parameters : {};
json.agencyName = 'my sheet';

var newSpreadSheet = getSheetNewDocument(json)
var sheet = newSpreadSheet.sheet;
Expand Down

0 comments on commit dc74b71

Please sign in to comment.