How do I format cells in workbook produced by xlsx package under Angular

十年热恋 提交于 2019-12-12 12:11:56

问题


NB. While primarily looking for an answer relating to the xlsx package (as it seems to be vastly suggested and discussed), I fear that it might be impossible. So, I'm also open to going in another direction (as long as it's free and works for Angular/Excel).

I've found xlxs and I'm producing Excel formatted files. I'd like to control a bit of the style so I added the property s to a cell as suggested in the comments (code sample here).

testMagic() {
  const table = document.getElementById("donkey");
  const workBook = XLSX.utils.table_to_book(table);
  workBook.Sheets.Sheet1.A1.s = { font: { bold: true } };
  XLSX.writeFile(workBook, "wonkey.xlsx");
}

I see no difference in the downloaded file, though. I've googled the issue but the combo Angular and xlsx and styling isn't commonly blogged.

I'm hoping it's something rather easy to resolve that I'm missing due to confusion and ignorance.


回答1:


I think you are using community(free) version of XLSX package. And the cell styling and other additional features to modify cell formats are only available in Pro version of the library. Please check here.

You can check official information here.

This is the community version. We also offer a pro version with performance enhancements, additional features like styling, and dedicated support.

P.S.- An alternative option to update the excel sheet and format the cells, use the exceljs npm package. you can see more details about styling here. See the example here(StackBlitz).



来源:https://stackoverflow.com/questions/55180480/how-do-i-format-cells-in-workbook-produced-by-xlsx-package-under-angular

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!