1.1.2 ā€¢ Published 12 days ago

jsonrawtoxlsx v1.1.2

Weekly downloads
-
License
MIT
Repository
github
Last release
12 days ago

āœØ What is jsonrawtoxlsx?

jsonrawtoxlsx is library to convert json raw (array) into xlsx file

āš”ļø Installation

using npm

npm install jsonrawtoxlsx

using yarn

yarn add jsonrawtoxlsx

using pnpm

pnpm add jsonrawtoxlsx

šŸš€ Usage

Use to save as file:

const jsonrawtoxlsx = require('jsonrawtoxlsx');
const fs = require('fs');

const json = [
  {
    name: 'John',
    age: 27,
    job: 'Software Engineer',
  },
];

const buffer = jsonrawtoxlsx(json);

fs.writeFileSync('example.xlsx', buffer, 'binary');

Or use as express middleware. It adds a convenience xlsx method to the response object to immediately output an excel as download.

const express = require('express');
const jsonrawtoxlsx = require('jsonrawtoxlsx');
const app = express();
const PORT = 3000;

const data = [
  {
    name: 'John',
    age: 27,
    job: 'Software Engineer',
  },
  {
    name: 'John',
    age: 27,
    job: 'Software Engineer',
  },
];

app.use(jsonrawtoxlsx.middleware);
app.get('/', function (req, res) {
  res.xlsx('example.xlsx', data);
});

app.listen(PORT, function (err) {
  if (err) console.log(err);
  console.log('Server listening on PORT', PORT);
});

šŸ¤ Contributing

Anyone can contribute with issues and PRs. If you're submitting a pull request, always create a new branch to work your changes, and try squashing commits down if possible. Always test any new code and make sure npm test passes and npm run test:cover for code coverage is adequate before opening a PR.

Author

šŸ‘¤ Arie Syukron

Show your support

Please ā­ļø this repository if this project helped you!

šŸ“ License

Copyright Ā© 2022 Arie Syukron. This project is MIT licensed.

happy coding!