https://github.com/zmecust/export-xlsx
Export excel
https://github.com/zmecust/export-xlsx
excel xlsx
Last synced: 2 months ago
JSON representation
Export excel
- Host: GitHub
- URL: https://github.com/zmecust/export-xlsx
- Owner: zmecust
- License: mit
- Created: 2019-08-17T08:06:27.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2023-03-03T05:30:09.000Z (over 3 years ago)
- Last Synced: 2025-10-02T08:52:20.105Z (9 months ago)
- Topics: excel, xlsx
- Language: JavaScript
- Size: 79.1 KB
- Stars: 13
- Watchers: 2
- Forks: 3
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# export-xlsx · [](https://github.com/zmecust/export-xlsx/blob/master/LICENCE) [](https://travis-ci.org/zmecust/export-xlsx) [](https://badge.fury.io/js/export-xlsx)
## Export Excel
- support formula
- hierarchy structure
- multi-headers
## Getting started
$ npm i -S export-xlsx
## Usage
### Make excel setting
```
import { alignment, defaultDataType } from 'export-xlsx';
// Export settings
export const SETTINGS_FOR_EXPORT = {
// Table settings
fileName: 'example',
workSheets: [
{
sheetName: 'example',
startingRowNumber: 2,
gapBetweenTwoTables: 2,
tableSettings: {
table1: {
tableTitle: "Score",
headerGroups: [
{
name: '',
key: 'void',
groupKey: 'directions',
},
{
name: 'Science',
key: 'science',
groupKey: 'directions',
},
{
name: 'Directions',
key: 'directions',
},
],
headerDefinition: [
{
name: '#',
key: 'number',
},
{
name: 'Name',
key: 'name',
},
{
name: 'SUM',
key: 'sum',
groupKey: 'void',
rowFormula: '{math}+{physics}+{chemistry}+{informatics}+{literature}+{foreignLang}',
},
{
name: 'Mathematics',
key: 'math',
groupKey: 'science',
},
{
name: 'Physics',
key: 'physics',
groupKey: 'science',
},
{
name: 'Chemistry',
key: 'chemistry',
groupKey: 'science',
},
{
name: 'Informatics',
key: 'informatics',
groupKey: 'science',
},
{
name: 'Literature',
key: 'literature',
groupKey: 'science',
},
{
name: 'Foreign lang.',
key: 'foreignLang',
groupKey: 'science',
},
{
name: 'AVG',
key: 'avg',
groupKey: 'void',
rowFormula: '{sum}/6',
}
],
}
}
},
],
};
```
### How to use
```
import ExcelExport from 'export-xlsx';
import { SETTINGS_FOR_EXPORT } from './setting';
const data = [
{
table1: [
{
number: 1,
name: 'Jack',
sum: '',
math: 1,
physics: 2,
chemistry: 2,
informatics: 1,
literature: 2,
foreignLang: 1,
avg: '',
},
{
number: 2,
name: 'Peter',
sum: '',
math: 2,
physics: 2,
chemistry: 1,
informatics: 2,
literature: 2,
foreignLang: 1,
avg: '',
},
]
}
];
const excelExport = new ExcelExport();
excelExport.downloadExcel(SETTINGS_FOR_EXPORT, data);
```
### Result

## Contact
If you have any questions, please contact me **`root@laravue.org`**
## License
The MIT license