feat : 年度计划生成功能及分摊汇总导出功能

This commit is contained in:
2024-07-06 02:21:26 +08:00
parent fce1708f5c
commit 8180c248ac
11 changed files with 471 additions and 38 deletions

View File

@@ -8,20 +8,34 @@ import XLSX from "xlsx-style-vite";
* @param columnLength 列长度
* @param excelName 导出文件名称
* @param bigWidthIndex 更宽列的索引
* @param bigWidthArray 更宽列数组索引
*/
export function exportExcel($table, columnLength, excelName, bigWidthIndex) {
export function exportExcel($table, columnLength, excelName, bigWidthIndex,bigWidthArray) {
//从el-table表生成工作簿对象
//使用原始的格式,保留表格中的格式如%、小数末尾的0等
let workbook = utils.table_to_book($table, {
raw: true
});
//列宽需要导出的表格有多少列这里的i就小于多少
for (let i = 1; i < columnLength; i++) {
if (i === bigWidthIndex) {
workbook.Sheets.Sheet1["!cols"].push({wpx: 300});
// if(bigWidthArray&&bigWidthArray.length>0){
// for (let i = 1; i < columnLength; i++) {
// for (let j = 0; j < bigWidthArray.length; j++) {
// console.log('bigWidthArray[j]',bigWidthArray[j])
// if (i === bigWidthArray[j]) {
// workbook.Sheets.Sheet1["!cols"].push({wpx: 300});
// }
// }
// workbook.Sheets.Sheet1["!cols"].push({wpx: 100});
// }
// }else {
for (let i = 1; i < columnLength; i++) {
if (i === bigWidthIndex) {
workbook.Sheets.Sheet1["!cols"].push({wpx: 300});
}
workbook.Sheets.Sheet1["!cols"].push({wpx: 100});
}
workbook.Sheets.Sheet1["!cols"].push({wpx: 100});
}
// }
//设置单元格样式
for (const key in workbook.Sheets.Sheet1) {
if (