Dino Geek, try to help you

How to generate Excel files from Node.js?


There are several modules available in Node.js that you can use to generate Excel files. Here are a few examples:

1. exceljs

First, install:
```
npm install exceljs
```
Then generate Excel:
```
let Excel = require(‘exceljs’);

let workbook = new Excel.Workbook();
let worksheet = workbook.addWorksheet(‘My Sheet’);

worksheet.columns = [ {header: ‘Id’, key: ‘id’}, {header: ‘Name’, key: ‘name’}, {header: ‘D.O.B.’, key: ‘dob’}
];

worksheet.addRow({id: 1, name: ‘John Doe’, dob: new Date(1970,1,1)});

workbook.xlsx.writeFile(‘MyExcelFile.xlsx’) .then(function() { console.log(‘File is written’); });
```

1. xlsx

First, install:
```
npm install xlsx
```
Then generate Excel:
```
let XLSX = require(‘xlsx’);

let workbook = XLSX.utils.book_new();
let worksheet = XLSX.utils.json_to_sheet([ {id: 1, name: ‘John Doe’, dob: ’01-01-1970’}, {id: 2, name: ‘Jane Doe’, dob: ’01-01-1970’}
]);

XLSX.utils.book_append_sheet(workbook, worksheet, ‘My Sheet’);
XLSX.writeFile(workbook, ‘MyExcelFile.xlsx’);
```

These are simple examples of creating an Excel file with a single worksheet and a few rows. Of course, these modules provide more complex functionality (such as formatting cells, adding multiple sheets, etc.) so you can check their respective documentation for more details.


Simply generate articles to optimize your SEO
Simply generate articles to optimize your SEO





DinoGeek offers simple articles on complex technologies

Would you like to be quoted in this article? It's very simple, contact us at dino@eiki.fr

CSS | NodeJS | DNS | DMARC | MAPI | NNTP | htaccess | PHP | HTTPS | Drupal | WEB3 | LLM | Wordpress | TLD | Domain name | IMAP | TCP | NFT | MariaDB | FTP | Zigbee | NMAP | SNMP | SEO | E-Mail | LXC | HTTP | MangoDB | SFTP | RAG | SSH | HTML | ChatGPT API | OSPF | JavaScript | Docker | OpenVZ | ChatGPT | VPS | ZIMBRA | SPF | UDP | Joomla | IPV6 | BGP | Django | Reactjs | DKIM | VMWare | RSYNC | Python | TFTP | Webdav | FAAS | Apache | IPV4 | LDAP | POP3 | SMTP

| Whispers of love (API) | Déclaration d'Amour |






Legal Notice / General Conditions of Use