node.js - excel4node lib 自动调整 excel 单元格以适应更长的文本

标签 node.js excel excel4node

使用 excel4node 库从一些 Web 表格中生成 excel 文档,是否可以在文本太长无法放入一个单元格时自动调整单元格大小并使单元格宽度变大?

documentation他们有这两个功能:

ws.column(3).setWidth(50);
ws.row(1).setHeight(20);

但这不适合里面的文本,只会让单元格变大。将显示示例:

enter image description here

和我想要的输出:

enter image description here

该评论单元格的代码:

reducedReport.forEach((element, index) => {
        ws.cell(index + 2, 1).string(element["projectName"]);
        ws.cell(index + 2, 2).string(element["workerName"]);
        ws.cell(index + 2, 3).string(element["comment"]);
        ws.column(3).setWidth(30);
        ws.row(15).setHeight(40);
        ws.cell(index + 2, 4).string(moment(element["date"] * 1000).format("DD-MM-YYYY"));
        console.log(element["comment"]);
    });

关于评论栏。

最佳答案

此功能尚未实现,as exposed in this GitHub issue。在那个问题 the author is pointing to an approximation approach used by PHPOffice 中,根据字体和内容的长度动态设置列的宽度。

关于node.js - excel4node lib 自动调整 excel 单元格以适应更长的文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52185784/

相关文章:

node.js - Mongoose 架构创建错误

node.js - 使用 NODEJS 将 POST 请求正文发送到网页

excel - 从工作表中删除特定形状

excel - for next 循环无法为变量分配值 - VBA

javascript - 将数组传递给函数 - PG 和 NodeJS

node.js - TypeORM:自定义多对多关系

vba - 循环遍历不同的工作表

node.js - Excel4Node:如何在不保存的情况下下载 Excel 文件?

javascript - Excel 电子表格未下载