Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.6k views
in Technique[技术] by (71.8m points)

XLSX 组件设置自适用excel宽度有没有?

XLSX 组件设置自适用excel宽度有没有大神会?

图1:
image.png

图2:
image.png

效果就是想导出之后直接就变成图2一样宽度自适用,或者加大宽度的效果


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

要再引入 xlsx-style 这个库,可以通过设置 sheet["!cols"]wch 属性来调整宽度。

所谓的自适应宽度,其实就是这列数据里最长的那行的宽度,全角字符2个宽、半角字符1个宽,最长的是多少你自己就能算出来。

P.S. 具体用法自行搜索“xlsx-style 列宽”吧。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...