如何在Angular下由xlsx包生成的工作簿中格式化单元格 [英] How do I format cells in workbook produced by xlsx package under Angular

查看:311
本文介绍了如何在Angular下由xlsx包生成的工作簿中格式化单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

NB.虽然主要是在寻找与xlsx软件包有关的答案(这似乎得到了广泛建议和讨论),但我担心这可能是不可能的.因此,我也愿意朝着另一个方向发展(只要它是免费的并且可用于Angular/Excel).

我发现 xlxs ,并且正在生成Excel格式的文件.我想控制一些样式,因此我按照在中的建议将属性 s 添加到单元格中注释(代码示例此处).

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");
}

不过,我发现下载的文件没有区别.我已经用谷歌搜索了这个问题,但是组合Angular和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.

推荐答案

我认为您正在使用XLSX软件包的社区(免费)版本.单元格样式和其他修改单元格格式的附加功能仅在该库的Pro版本中可用.请在此处查看.

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.

您可以在此处查看官方信息.

这是社区版本.我们还提供了一个专业版, 性能增强,样式等其他功能,以及 专门的支持.

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

PS-一种替代选项,用于更新excel工作表并格式化单元格,请使用此处中查看有关样式的更多详细信息. 参见示例此处(StackBlitz).

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).

这篇关于如何在Angular下由xlsx包生成的工作簿中格式化单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆