1.0.8 • Published 3 years ago

xlsx-rw v1.0.8

Weekly downloads
1
License
MIT
Repository
-
Last release
3 years ago

Excel Read/Write utilitiesLicense NPM version NPM downloads

Utility to read, write and update excels using xlsx

RoadMap

This is a finished library with docs missing:

x Write typescript documentation Update docs ExcelReader Write ExcelWriter docs

ExcelReader

A class to read excel sheet

import { ExcelReader } from 'xlsx-rw';

const excelPath = 'excel.xlsx';
const excel = new ExcelReader(excelPath);

// Read from excel 3 colums (A, B, C) starting from first row
// until a row with no content in the columns (A, B, C) is found
const reader = excel.readRows('Seet1', 3);
let nextRow = reader.next();
while (!nextRow.done) {
    const [, b, c] = nextRow.value;
    const month = new Date(dTo.w).getMonth();
    // See more cell fields in https://www.npmjs.com/package/xlsx#cell-object
    console.log(b.t); // Cell type
    console.log(b.v); // Value
    console.log(b.w); // Text
    console.log(b.z); // Format
    console.log(b.f); // Formula
    nextRow = reader.next();
}

// Read from excel columns C, D, K, read rows 1-10
const reader = excel.readRows('Seet1', ['C', 'D', 'K'], 10);

// Read from excel columns C, D, K, starting on row 2 (skip headers row)
// until an empty row in C, D, K is found
const reader = excel.readRows('Seet1', ['C', 'D', 'K'], undefined, 2);

ExcelWritter

import { Workbook } from 'xlsx-rw';

const strText = `This text contains
multiple lines`;

// Generate excel sheet with some rows
const arrOfArrs = [
    ['Header text', 'Header long text', 'Header boolean', 'Header date'],
    ['value1', strText.replace(/[\r\n]+/g, '\r\n'), 2, false, new Date()],
];

const wb = new Workbook().writeData('sheet name', arrOfArrs);
const excelLocation = 'excel.xlsx';
wb.save(excelLocation);
1.0.8

3 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago