使用excel4node lib从一些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"]);
});这是关于评论栏的。
发布于 2019-09-05 16:26:21
这个功能还没有实现,as exposed in this GitHub issue。在这个问题中,the author is pointing to an approximation approach used by PHPOffice根据字体和内容长度动态设置列的宽度。
发布于 2018-12-18 23:18:25
可以为单元格设置添加对齐设置:
alignment: {
shrinkToFit: true,
wrapText: true
}https://stackoverflow.com/questions/52185784
复制相似问题