fix : 修复导出表格宽度

This commit is contained in:
2024-06-21 15:31:06 +08:00
parent b73b9aad4b
commit bce9b2d8d2
3 changed files with 6 additions and 3 deletions

View File

@@ -8,7 +8,7 @@ import XLSX from "xlsx-style-vite";
* @param columnLength 列长度
* @param excelName 导出文件名称
*/
export function exportExcel($table, columnLength, excelName) {
export function exportExcel($table, columnLength, excelName,bigWidth) {
//从el-table表生成工作簿对象
//使用原始的格式,保留表格中的格式如%、小数末尾的0等
let workbook = utils.table_to_book($table, {
@@ -16,6 +16,9 @@ export function exportExcel($table, columnLength, excelName) {
});
//列宽需要导出的表格有多少列这里的i就小于多少
for (let i = 1; i < columnLength; i++) {
if(i==bigWidth){
workbook.Sheets.Sheet1["!cols"].push({wpx: 300});
}
workbook.Sheets.Sheet1["!cols"].push({wpx: 100});
}
//设置单元格样式