小编Onu*_*Arı的帖子

使用 Angular 2 生成 Docx 文件

我正在使用 angular2 并且我想使用一个对象生成一个 docx 文件。我希望我的 docx 文件包含页脚、页眉、表格等。我能想到的最佳解决方案是首先创建一个 HTML 文件,然后将其转换为 docx 文件。但这似乎不对。有没有更简单方便的方法来做我想做的事情?这是我使用的方法:

exportAsDoc() {

const preHtml = '<html xmlns:o=\'urn:schemas-microsoft-com:office:office\' ' + '' +
        ' xmlns:w=\'urn:schemas-microsoft-com:office:word\' xmlns=\'http://www.w3.org/TR/REC-html40\'><head><meta charset=\'utf-8\'>' +
        '<title>Export HTML To Doc</title></head><body>';
const postHtml = '</body></html>';

let innerHtml = '';
// Specify file name
const filename = this.respSheet.title + '.doc';
const respSheetKpis = this.respSheet.sheet_kpis;
respSheetKpis.forEach(x => {
  const footer = '<p style="text-align: center">' + x.kpi.name + ' - ' + x.kpiValue + '</p>';
  innerHtml += footer;
  x.sheet_kpi_dimensions.forEach(dimension => {
    if (dimension.dimension …
Run Code Online (Sandbox Code Playgroud)

docx typescript angular

2
推荐指数
1
解决办法
1万
查看次数

标签 统计

angular ×1

docx ×1

typescript ×1