使用 js-xlsx 导出 .xlsx 文件时如何设置单元格宽度 [英] How to set cell width when export .xlsx files with js-xlsx

查看:380
本文介绍了使用 js-xlsx 导出 .xlsx 文件时如何设置单元格宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 js-xlsx 为导出的 excel 文件设置固定的列/单元格宽度.

这里是js-xlsx的源码:

为了快速参考,其中 ws 是您的工作表.

var wscols = [{wch:6},{wch:7},{wch:10},{wch:20}];ws['!cols'] = wscols;

I am trying to set a fixed column/cell width to my exported excel files with js-xlsx.

EDIT:

Here is the source of js-xlsx: https://github.com/SheetJS/js-xlsx

解决方案

I found a snippet the the write test here https://github.com/SheetJS/js-xlsx/blob/master/tests/write.js#L14-L19

For quick reference, where ws is your worksheet.

var wscols = [
    {wch:6},
    {wch:7},
    {wch:10},
    {wch:20}
];

ws['!cols'] = wscols;

这篇关于使用 js-xlsx 导出 .xlsx 文件时如何设置单元格宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆