|
@@ -80,10 +80,10 @@ const ExcelWriter = {
|
|
|
|
|
|
async outputExcelByData(data: Array<any>, options: Options) {
|
|
|
let columnArray = this.getColumnNames(); //await ExcelWriter.getColumnNames();
|
|
|
- console.log("#debug#🚀 ~ file: test.vue:36 ~ testOne2Two ~ columnArray:", columnArray);
|
|
|
+ //console.log("#debug#🚀 ~ file: test.vue:36 ~ testOne2Two ~ columnArray:", columnArray);
|
|
|
//rowSpan span
|
|
|
let arrayOrg = data;
|
|
|
- console.log("#debug#🚀 ~ file: test.vue:42 ~ testOne2Two ~ arrayOrg:", JSON.stringify(arrayOrg));
|
|
|
+ //console.log("#debug#🚀 ~ file: test.vue:42 ~ testOne2Two ~ arrayOrg:", JSON.stringify(arrayOrg));
|
|
|
let maxRow: number = 0;
|
|
|
let maxColumn: number = 0;
|
|
|
arrayOrg.forEach((item) => {
|
|
@@ -97,34 +97,34 @@ const ExcelWriter = {
|
|
|
if (column > maxColumn) {
|
|
|
maxColumn = column;
|
|
|
}
|
|
|
- console.log("#debug#🚀 ~ file: test.vue:47 ~ arrayOrg.forEach ~ num:", column, maxColumn);
|
|
|
- console.log("#debug#🚀 ~ file: test.vue:46 ~ testOne2Two ~ letters:", letters, columnArray.indexOf(letters));
|
|
|
+ //console.log("#debug#🚀 ~ file: test.vue:47 ~ arrayOrg.forEach ~ num:", column, maxColumn);
|
|
|
+ //console.log("#debug#🚀 ~ file: test.vue:46 ~ testOne2Two ~ letters:", letters, columnArray.indexOf(letters));
|
|
|
});
|
|
|
let excelData = [] as any;
|
|
|
- console.log("#debug#🚀 ~ file: test.vue:67 ~ testOne2Two ~ maxRow:", maxRow);
|
|
|
- console.log("#debug#🚀 ~ file: test.vue:70 ~ testOne2Two ~ maxColumn:", maxColumn);
|
|
|
+ //console.log("#debug#🚀 ~ file: test.vue:67 ~ testOne2Two ~ maxRow:", maxRow);
|
|
|
+ //console.log("#debug#🚀 ~ file: test.vue:70 ~ testOne2Two ~ maxColumn:", maxColumn);
|
|
|
for (let i = 0; i <= maxColumn; i++) {
|
|
|
excelData[i] = [];
|
|
|
for (let j = 0; j <= maxRow; j++) {
|
|
|
excelData[i][j] = null;
|
|
|
}
|
|
|
}
|
|
|
- console.log("#debug#🚀 ~ file: test.vue:75 ~ arrayOrg.forEach ~ excelData:", excelData);
|
|
|
+ //console.log("#debug#🚀 ~ file: test.vue:75 ~ arrayOrg.forEach ~ excelData:", excelData);
|
|
|
arrayOrg.forEach((item) => {
|
|
|
let letters = item.poi.replace(/[^a-z]/gi, "").toUpperCase();
|
|
|
let num = item.poi.replace(/\D/g, "");
|
|
|
let row = columnArray.indexOf(letters);
|
|
|
excelData[num - 1][row] = item;
|
|
|
});
|
|
|
- console.log("#debug#🚀 ~ file: test.vue:75 ~ arrayOrg.forEach ~ excelData:", excelData);
|
|
|
+ //console.log("#debug#🚀 ~ file: test.vue:75 ~ arrayOrg.forEach ~ excelData:", excelData);
|
|
|
|
|
|
- console.log("#debug#🚀 ~ file: ExcelWriter.ts:82 ~ outputExcelByData ~ options:", options);
|
|
|
+ //console.log("#debug#🚀 ~ file: ExcelWriter.ts:82 ~ outputExcelByData ~ options:", options);
|
|
|
if (options?.border) {
|
|
|
//如果有边框
|
|
|
excelData.forEach((row: any, rowIndex: number) => {
|
|
|
- console.log("#debug#🚀 ~ file: ExcelWriter.ts:87 ~ data.forEach ~ row:", row);
|
|
|
+ //console.log("#debug#🚀 ~ file: ExcelWriter.ts:87 ~ data.forEach ~ row:", row);
|
|
|
row.forEach((cell: any, cellIndex: number) => {
|
|
|
- console.log("#debug#🚀 ~ file: ExcelWriter.ts:87 ~ data.forEach ~ cell:", cell);
|
|
|
+ //console.log("#debug#🚀 ~ file: ExcelWriter.ts:87 ~ data.forEach ~ cell:", cell);
|
|
|
let borderColor = "#000000";
|
|
|
if (cell) {
|
|
|
if (options?.borderColor) {
|
|
@@ -135,11 +135,11 @@ const ExcelWriter = {
|
|
|
}
|
|
|
cell.borderColor = borderColor;
|
|
|
// cell.borderColor = options?.borderColor ?? "#000000";
|
|
|
- console.log("#debug#🚀 ~ file: ExcelWriter.ts:87 ~ data.forEach ~ cell.borderColor:", cell.borderColor);
|
|
|
+ //console.log("#debug#🚀 ~ file: ExcelWriter.ts:87 ~ data.forEach ~ cell.borderColor:", cell.borderColor);
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
- console.log("#debug#🚀 ~ file: ExcelWriter.ts:90 ~ data.forEach ~ data:", data);
|
|
|
+ //console.log("#debug#🚀 ~ file: ExcelWriter.ts:90 ~ data.forEach ~ data:", data);
|
|
|
}
|
|
|
if (!options.hasOwnProperty("fileName")) {
|
|
|
// 对象 options 上没有名为 "fileName" 的属性
|