istvandesign / excol

"Google sheets" mock

Home Page:https://darul75.github.io/excol/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

excol

Build Status codecov

Library to mock excel(-like) solutions in Javascript.

Why

You may (should) write your own tests before deploying your code to solution like Google sheet or Office 365.

Idea

In case of google app script, you can use their own editor to play with simple scripts but for bigger project it will become very complex to maintain.

What you may need is a tool to work locally and push back your changes to Google.

How to use

Google app script language is Javascript, a kind of, not ECMA 5 but an old one with most the basic necessary native features.

With starter kit provided before, you can named your files with .js extensions and play with it in a NodeJS environment (Tests).

Using a CJS manner, you just need to enhance your files a little bit this way.

MyFunctions.js

/**
 * NodeJS part for tests
 */
if (typeof exports === 'object' && typeof module !== 'undefined') {
  var excol = require('excol');
  var SpreadsheetApp = excol.SpreadsheetApp;
}

function read() {
  var activeSheet = SpreadsheetApp.getActiveSheet();
  var range = activeSheet.getRange("A1:B2");
}

function write() {
  var activeSheet = SpreadsheetApp.getActiveSheet();
  var range2 = activeSheet.getRange(1,1,2,2);
    range2.setValues([
    [1,2],
    [3,4]
  ]);
}

/**
 * NodeJS part for tests
 **/
if (typeof exports === 'object' && typeof module !== 'undefined') {
  module.exports = {
    read: read,
    write: write
  };
  //
  // module.exports = read; 
}

Main.js

/**
 * NodeJS part for tests
 */
if (typeof exports === 'object' && typeof module !== 'undefined') {
  var MyFunctions = require('MyFunctions');
}

function main() {
  MyFunctions.read();
  MyFunctions.write();
}

About

"Google sheets" mock

https://darul75.github.io/excol/

License:MIT License


Languages

Language:TypeScript 98.8%Language:JavaScript 1.2%