Skip to content

Commit

Permalink
Complete cell with properties
Browse files Browse the repository at this point in the history
  • Loading branch information
matheusmr13 committed Jul 19, 2016
1 parent 029c193 commit bb72c70
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions src/SheetsTemplater.gs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ var QuickDrive = function (DriveApp, SpreadsheetApp, newConfig) {
permissions: [{
access: DriveApp.Access.ANYONE_WITH_LINK,
permission: DriveApp.Permission.VIEW
}]
}],
byField: {}
};
this._config = _config;
var validateConfig = function (config) {
Expand Down Expand Up @@ -182,17 +183,9 @@ var QuickDrive = function (DriveApp, SpreadsheetApp, newConfig) {
sheet.getRange(row, col).setValue(getValueOnJson(json, command.substring(2, command.length - 1)));
};

function completeCell(properties) {
var row = properties.i + 1,
col = properties.j + 1,
command = properties.values[properties.i][properties.j],
sheet = properties.sheet,
json = properties.json,
cellProperties = getValueOnJson(json, command.substring(2, command.length - 1)),
range = sheet.getRange(row, col);
if (cellProperties.value) {
range.setValue(cellProperties.value);
}
function setCellProperties(sheet, cellProperties) {
var range = sheet.getRange(cellProperties.row, cellProperties.col);
range.setValue(cellProperties.value || '');
if (cellProperties.backgroundColor) {
range.setBackground(cellProperties.backgroundColor);
}
Expand All @@ -206,10 +199,23 @@ var QuickDrive = function (DriveApp, SpreadsheetApp, newConfig) {
range.setBorder(true, true, true, true, true, true, cellProperties.borderColor, SpreadsheetApp.BorderStyle[cellProperties.borderStyle]);
}
if (cellProperties.rowSpan) {
sheet.getRange(row, col, 1, parseInt(cellProperties.rowSpan, 10)).merge();
sheet.getRange(cellProperties.row, cellProperties.col, 1, parseInt(cellProperties.rowSpan, 10)).merge();
}
};

function completeCell(properties) {
var row = properties.i + 1,
col = properties.j + 1,
command = properties.values[properties.i][properties.j],
sheet = properties.sheet,
json = properties.json,
cellProperties = getValueOnJson(json, command.substring(2, command.length - 1));

cellProperties.row = row;
cellProperties.col = col;
setCellProperties(sheet, cellProperties);
};

function insertFormula(properties) {
var row = properties.i + 1,
col = properties.j + 1,
Expand All @@ -225,7 +231,6 @@ var QuickDrive = function (DriveApp, SpreadsheetApp, newConfig) {
};

this.processSheet = function (json) {

var newSpreadSheet = getSheetNewDocument();
var sheet = newSpreadSheet.sheet;
var range = sheet.getRange(1, 1, sheet.getMaxRows(), sheet.getMaxColumns());
Expand Down

0 comments on commit bb72c70

Please sign in to comment.