- SheetJS/sheetjs#642
- SheetJS/sheetjs#364
- https://stackoverflow.com/questions/50110595/how-to-add-cell-border-to-sheetjs-xlsx-generated-file
A lot of features as add image or style cell are available only on Pro account.
There is a repo that fork the original one and that allow format options but has no well support: npm i fixed-xlsx-style
.
Link: https://github.com/exceljs/exceljs
Version 3.x
has not well Angular support. There are some issues related to the use of this library on it, but the first link explain how to use version 1.12
with success.
- https://www.ngdevelop.tech/export-to-excel-in-angular-6/
- https://github.com/exceljs/exceljs/issues?utf8=%E2%9C%93&q=is%3Aissue+angular
Basic usage:
import { Workbook } from 'exceljs';
// ...code
const woorkbook = new Workbook();
const worksheet = woorkbook.addWorksheet('SheetName');
worksheet.columns = <someArrayOfObjects>.cols.map((col) => ({ header: col.label, key: col.label, width: 10 }));
// add image inside a sheet
const image = workbook.addImage({
base64: 'some base64 image',
extension: 'png',
});
worksheet.addImage(image, {
editAs: 'absolute',
tl: { col: 0, row: 20 },
ext: { width: 400, height: 150 },
});
// download the workbook
const buffer = await workbook.xlsx.writeBuffer();
const blob = new Blob([buffer], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' });
saveAs(blob, 'test.xlsx');