html2xlsx

0.4.2 • Public • Published

html2xlsx

Transform html to excel (just support xlsx)

NPM version NPM downloads Build Status Coverage Status Dependency Status Greenkeeper badge


Install

$ npm install html2xlsx

Usage

const fs = require('fs');
const htmlTo = require('html2xlsx');

htmlTo(`
  <style type="text/css">
    table td {
      color: #666;
      height: 20px;
      background-color: #f1f1f1;
      border: 1px solid #eee;
    }
  </style>
  <table>
    <tr>
      <td>foo</td>
      <td>bar</td>
    </tr>
    <tr>
      <td>hello</td>
      <td>world</td>
    </tr>
    <tr>
      <td type="number">123</td>
      <td type="number">123.456</td>
    </tr>
    <tr>
      <td data-type="bool">true</td>
      <td data-type="bool">false</td>
    </tr>
    <tr>
      <td data-type="bool">1</td>
      <td data-type="bool">0</td>
    </tr>
    <tr>
      <td type="formula">SUM(A1:B1)</td>
      <td type="formula">A1-B1</td>
    </tr>
    <tr>
      <td type="date">2013-01-12T12:34:56+08:00</td>
      <td type="datetime">2013-01-12T12:34:56+08:00</td>
    </tr>
  </table>
`, (err, file) => {
  if (err) return console.error(err);
  
  file.saveAs()
    .pipe(fs.createWriteStream('test.xlsx'))
    .on('finish', () => console.log('Done.'));
});

Report a issue

Reference

License

html2xlsx is available under the terms of the MIT License.

Readme

Keywords

Package Sidebar

Install

npm i html2xlsx

Weekly Downloads

34

Version

0.4.2

License

MIT

Unpacked Size

11.3 kB

Total Files

4

Last publish

Collaborators

  • d-band