From 3d9d07a04299d9d43c8b4faa3192c7233c338026 Mon Sep 17 00:00:00 2001
From: gaoluyang <gaoluyang@rengu.cc>
Date: 星期四, 11 七月 2024 15:09:30 +0800
Subject: [PATCH] 科学计数法逻辑修改
---
src/util/excelFountion.js | 36 ++++++++++++++++++++++++++++++++----
1 files changed, 32 insertions(+), 4 deletions(-)
diff --git a/src/util/excelFountion.js b/src/util/excelFountion.js
index 75988a1..80c6e2e 100644
--- a/src/util/excelFountion.js
+++ b/src/util/excelFountion.js
@@ -133,6 +133,27 @@
}
}
+/**
+ * 璁$畻骞�
+ *
+ * @param str 瀛楃涓插舰寮忕殑骞傝〃杈惧紡锛屼緥濡�"2^3"
+ * @returns 杩斿洖璁$畻鍚庣殑骞傚�硷紝濡傛灉琛ㄨ揪寮忔棤鏁堝垯杩斿洖null
+ */
+function CalculatePower(str){
+ try {
+ if(str&&str.includes('^')){
+ let arr = str.split('^');
+ if(arr&&arr.length>1){
+ return Math.pow(arr[0],arr[1]);
+ }else{
+ return null;
+ }
+ }
+ } catch (error) {
+
+ }
+}
+
/**
@@ -248,9 +269,9 @@
'MAX',
'MIN',
'AVERAGE',
- 'APS',
+ 'ABS',
]
- f = f.replace(regex, ',')
+ f = f.replace(regex, ',').replaceAll('"&','').replaceAll('&"','')
fouList.forEach(item=>{
f = f.replaceAll(item,',')
})
@@ -294,8 +315,15 @@
// 鑾峰彇鍗曞厓鏍煎搴斿��
let arr = getAllCell(f)
for (var a in comValue) {
- if(comValue[a]!=='undefine'&&comValue[a]!=='null'&&comValue[a]!==undefined){
- arr[a] = comValue[a]
+ if(comValue[a]!=='undefined'&&comValue[a]!=='null'&&comValue[a]!==undefined){
+ if(typeof(comValue[a])=='string'&&comValue[a].includes('^')){
+ // 璁$畻骞傛
+ arr[a] = CalculatePower(comValue[a])
+ } else if (typeof(comValue[a])=='string'&&comValue[a].includes('/')) {
+ arr[a] = comValue[a]
+ } else{
+ arr[a] = comValue[a]
+ }
}
}
// 瑙f瀽鍏紡鍙傛暟锛岀壒鍒槸甯︼細鐨�
--
Gitblit v1.9.3