明树Git Lab

Commit 10d70d3a authored by zfp1's avatar zfp1

update

parent 3105652c
Pipeline #108205 passed with stage
in 3 seconds
......@@ -57,7 +57,7 @@ async function getXmtzzjllTem({ startYear, endYear, tampName, projectId }) {
rows = Array(worksheet.actualRowCount - 3).fill(Array(columns.length).fill(""))
}
} else {
rows = Array(worksheet.actualRowCount - 3).fill(Array(columns.length).fill(""))
rows = Array(worksheet.actualRowCount - 3).fill(Array(columns.length).fill(0))
}
// console.log(rows, "=============")
......@@ -89,7 +89,7 @@ async function getXmtzzjllTem({ startYear, endYear, tampName, projectId }) {
worksheet.eachRow((row, rowNumber) => {
row.eachCell((cell, colNumber) => {
if (rowNumber >= 4 && rowNumber <= worksheet.actualRowCount && colNumber >= 4 && colNumber <= (3 + columns.length)) {
cell.numFmt = '#,##0.00'; //数字格式
// cell.numFmt = '#,##0.00'; //数字格式
}
cell.alignment = {
horizontal: 'center',
......@@ -99,6 +99,9 @@ async function getXmtzzjllTem({ startYear, endYear, tampName, projectId }) {
cell.border = BLACK_BORDER; //边框
if (tampName == "tjjh") {
let enColNum = getExcelColumnLetter(colNumber)
if([4, 14,25, 32].includes(rowNumber)){
cell.value = "";
}
if (rowNumber == 13 && colNumber >= 4) {
cell.value = { formula: `=SUM(${enColNum}5,${enColNum}8,${enColNum}11)` }
}
......@@ -120,6 +123,7 @@ async function getXmtzzjllTem({ startYear, endYear, tampName, projectId }) {
if (rowNumber == 41 && colNumber >= 4) {
cell.value = { formula: `=SUM(${enColNum}42-${enColNum}43)` }
}
}
});
});
......@@ -198,6 +202,7 @@ async function importExcelTempData(req, res, next) {
worksheet.eachRow({ includeEmpty: true }, (row, ri) => {
const rowData = [];
row.eachCell({ includeEmpty: true }, (cell, ci) => {
console.log(cell.value, "===")
if (cell.formula) {
rowData.push(cell.formula);
} else if (cell.type === ExcelJS.ValueType.String) {
......@@ -214,15 +219,25 @@ async function importExcelTempData(req, res, next) {
});
sheetData.push(rowData);
});
hf.addSheet('Sheet1'); // 先建表
hf.setSheetContent(0, sheetData); // 灌数据+公式
hf.addSheet('Sheet1'); // 先建表
hf.setSheetContent(0, sheetData); // 灌数据+公式
const { height, width } = hf.getSheetDimensions(0);
const out = [];
for (let r = 0; r < height; r++) {
let cc = [];
for (let c = 0; c < sheetData[0].length; c++) {
// const formulaString = hf.getCellFormula({ sheet: 0, row: r, col: c });
let calculated = hf.getCellValue({ sheet: 0, row: r, col: c });
let calculated = hf.getCellValue({ sheet: 0, row: r, col: c });
// console.log( calculated, " === ")
try {
const result = hf.calculateFormula("=" + calculated, 0)
// console.log(typeof result, "-----------------")
if(typeof result == "number") {
calculated = result;
}
} catch (error) {
// console.log(error)
}
// console.log(formulaString, calculated)
if (typeof calculated == 'string') {
calculated = removeSuffix(String(calculated), '_suffix')
......
......@@ -64,7 +64,7 @@ function checkPath(path) {
const allowedPatterns = [
/^\/user\/login$/,
/^\/user\/regist$/,
/^\/template\/getExcelTemplate$/,
/^\/template\/getExcelTemplate2$/,
/^\/file\/download\/\d+$/,
/^\/file\/show\/\d+$/,
];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment