Browse Source

修改工具

lanyunfei 1 month ago
parent
commit
905bf2ad6a
2 changed files with 9 additions and 1 deletions
  1. 4 0
      dist/ExcelUtil.js
  2. 5 1
      src/ExcelUtil.ts

+ 4 - 0
dist/ExcelUtil.js

@@ -414,6 +414,10 @@ var ExcelUtil = /** @class */ (function () {
                         }
                     }
                 }
+                //最多保留两位小数
+                if (typeof value === 'number' && !isNaN(value)) {
+                    value = parseFloat(value.toFixed(2));
+                }
                 values.push(value);
             }
             if (headInfo.keys.length != values.length) {

+ 5 - 1
src/ExcelUtil.ts

@@ -404,7 +404,11 @@ export default class ExcelUtil {
                         }
                     }
                 }
-                values.push(value)
+                //最多保留两位小数
+                if(typeof value === 'number' && !isNaN(value)){
+                    value = parseFloat(value.toFixed(2))
+                }
+               values.push(value)
             }
             if (headInfo.keys.length != values.length) {
                 Config.checkState(RetCode.EXCEL_DATA_ERROR, `${StringUtil.getCheckString(address, headInfo)} 数据错误5!`)