This project showcases downloading client side .xlsx files with a few customization option. Unlike SheetJS, this is a lightweight solution(<100kb). Lots of room for improvement. :)
npm run serve
- To serve.
IE supported but requires prod build - npm run preview
const data = [{...}] (Array of objects)
const config = {
displayedColums: ['objKey'] // Order of columns to be displayed. If null/empty then alphabetical order is maintained.
boldHeaders: boolean // default: true,
upperCaseHeaders: boolean //default: false
wrapAll: boolean // default: false,
getCellStyle: (rowIndex, colIndex, cellData) => number/obj // expects a predefined style number or object.
colConfig: [
{
colKey: 'key', //column key
width: number // width
}....
]
}
const xlsx = new XLSX().create(data, config)
-JSZip
-FileSaver(can be replaced with a custom solution)
getCellStyle expects one of the following:
-
Number:
normal: 0
bold text: 2
wrap text: 10
wrap & bold text: 11
-
Object literal containing following properties(optional):
fontType: 0/2/10/11 border: true/false, fontColor: '#FCFCFC', bgColor: '#EEEEEE', wrap: true/false, alignment: 'right/left/center/flll'
- Vite JS
- ExcelHTML5
- OpenXML