Coder Social home page Coder Social logo

workbook's Introduction

workbook

Wrapper for SheetJS/js-xlsx providing convenient way to accumulate sheets, rows, styles.

NPM

Install

  • npm install workbook --save
  • npm install js-xlsx --save

Note that this can also wrap other versions of js-xlsx, e.g. protobi/js-xlsx, to allow application of styles using the .s attribute instead:

  • npm install js-xlsx-style --save

Use

var XLSX = require('xlsx');
var Workbook = require('./workbook');

var workbook = new Workbook()
    .addRowsToSheet("Main", [
      [
        {
           v: "This is a submerged cell",
           s:{
             border: {
               left: {style: 'thick', color: {auto: 1}},
               top: {style: 'thick', color: {auto: 1}},
               bottom: {style: 'thick', color: {auto: 1}}
             }
             }
        },
        {
             v: "Pirate ship",
             s:{
               border: {
                 top: {style: 'thick', color: {auto: 1}},
                 bottom: {style: 'thick', color: {auto: 1}}
               }
             }
        },
        {
             v: "Sunken treasure",
             s:{
               border: {
                 right: {style: 'thick', color: {auto: 1}},
                 top: {style: 'thick', color: {auto: 1}},
                 bottom: {style: 'thick', color: {auto: 1}}
               }
             }
        }
       ],
      [
        {"v": "Blank"},
        {"v": "Red", "s": {fill: { fgColor: { rgb: "FFFF0000"}}}},
        {"v": "Green", "s": {fill: { fgColor: { rgb: "FF00FF00"}}}},
        {"v": "Blue", "s": {fill: { fgColor: { rgb: "FF0000FF"}}}}
      ],
      [
        {"v": "Default"},
        {"v": "Arial", "s": {font: {name: "Arial", sz: 24}}},
        {"v": "Times New Roman", "s": {font: {name: "Times New Roman", sz: 16}}},
        {"v": "Courier New", "s": {font: {name: "Courier New", sz: 14}}}
      ],
      [
        0.618033989,
        {"v": 0.618033989},
        {"v": 0.618033989, "t": "n"},
        {"v": 0.618033989, "t": "n", "s": { "numFmt": "0.00%"}},
        {"v": 0.618033989, "t": "n", "s": { "numFmt": "0.00%"}, fill: { fgColor: { rgb: "FFFFCC00"}}},
        [(new Date()).toLocaleString()]
      ]
    ]).mergeCells("Main", {
      "s": {"c": 0, "r": 0 },
      "e": {"c": 2, "r": 0 }
    }).finalize();

var OUTFILE = '/tmp/wb.xlsx';
XLSX.writeFile(workbook, OUTFILE, {defaultCellStyle: { font: {name: 'Arial', sz: '12'}}});
console.log("Results written to " + OUTFILE)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.