使用 excel4node 库从一些 Web 表格中生成 excel 文档,是否可以在文本太长无法放入一个单元格时自动调整单元格大小并使单元格宽度变大?
在documentation他们有这两个功能:
ws.column(3).setWidth(50);
ws.row(1).setHeight(20);
但这不适合里面的文本,只会让单元格变大。将显示示例:
和我想要的输出:
该评论单元格的代码:
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/