0.3.1-beta • Published 1 year ago

node-sheet v0.3.1-beta

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

NODE-SHEET (beta)

GitHub repo size GitHub language count GitHub forks Bitbucket open issues

A simple way to create spreadsheets.

Disclaimer

It is not recommended to use this library in real projects.

Installing node-sheet

Use one of the commands below to install the node-sheet:

npm install node-sheet
yarn add node-sheet
pnpm add node-sheet

Using node-sheet

ClassDescription
WorkbookMain class that manages the worksheet
WorksheetClass that manages each sheet page
ColumnClass used to build each column of the worksheet
HeaderClass used to add the headers of each column that is able to define patterns for all the cells of the column
CellClass used to insert rows to the column

Here's how you can create a basic spreadsheet containing name, age and gender:

const { Worksheet, Column, Header, Cell, Workbook } = require('node-sheet');

const worksheet = new Worksheet('Page 1');  // Page 1 is the page name

worksheet.addColumns([
  new Column({
    header: new Header({ title: 'Name' }),
    cells: [new Cell('John'), new Cell('Maria'), new Cell('Joseph')],
  }),
  new Column({
    header: new Header({ title: 'Age' }),
    cells: [new Cell(20), new Cell(30), new Cell(40)],
  }),
  new Column({
    header: new Header({ title: 'Gender' }),
    cells: [new Cell('Male'), new Cell('Female'), new Cell('Male')],
  }),
]);

new Workbook().addWorksheet(worksheet).export('worksheet-name');

Pay attention: the cells will be organized according to the order they are arranged in cells.

the export method will create a sheet at the root named according to the string passed by parameter. The result will be a spreadsheet like this:

NameAgeGender
John20Male
Maria30Female
Joseph40Male
0.3.0-beta

1 year ago

0.3.1-beta

1 year ago

0.2.3

2 years ago

0.2.2

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago