Skip to content

Simple generator of XLSX files from Javascript

Notifications You must be signed in to change notification settings

healthcarelogic/MyExcel

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MyExcel

npm

  • Install
npm i --save myexcel
  • Code
const myexcel = require('myexcel');

const testData = [
  { 'Column 1': 'Test' },
  { 'Column 1': 'Test Again' },
];

const excel = myexcel.new('Calibri light 10 #333333');

const headers = Object.keys(testData[0]);

const formatHeader = excel.addStyle({ border: 'none,none,none,thin #333333',
  font: 'Calibri 12 #0000AA B' });

for (let i = 0; i < headers.length; i++) {
  excel.set(0, i, 0, headers[i], formatHeader);
  excel.set(0, i, undefined, 'auto');
}

for (let i = 0; i < testData.length; i++) {
  const data = Object.values(testData[i]);
  for (let j = 0; j < headers.length; j++) {
    excel.set(0, j, i + 1, data[j].toString());
  }
}

excel.generate('test.xlsx', () => {
  console.log('exporting is done');
});

Browser

Simple generator of XLSX files from Javascript

To demo it try this sample. Look at its source code.

It so simple that no documentation is required. Contact me for bugs, requests, ideas,...

Licensed under MIT, but if you use it, I´d appreciate if you let me know.

About

Simple generator of XLSX files from Javascript

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 98.6%
  • HTML 1.4%