xyxie hace 1 año
padre
commit
c74421d91f
Se han modificado 1 ficheros con 2 adiciones y 13 borrados
  1. 2 13
      services/data/excel/mixed_table.go

+ 2 - 13
services/data/excel/mixed_table.go

@@ -1219,26 +1219,15 @@ func handleMixCellShowStyle(showStyleList []string, calculateCellMap map[string]
 }
 
 // changePointDecimalPlaces 小数点位数加减和百分比格式
-func changePointDecimalPlaces(str string, changeNum int, numberType string) (newStr string) {
+func changePointDecimalPlaces(str string, pointNum int, numberType string) (newStr string) {
 	newStr = str
-	if changeNum == 0 { //无需改变
-		return
-	}
-	var decimalPlaces int               // 计算小数位数
-	dotIndex := strings.Index(str, ".") // 查找小数点的位置
-	if dotIndex == -1 {
-		decimalPlaces = 0
-	} else {
-		decimalPlaces = len(str) - dotIndex - 1
-	}
 	// 把字符串转成浮点数
 	val, _ := strconv.ParseFloat(str, 64)
 	// 如果有,则处理百分位,
 	if numberType == "percent" {
 		val = val * 100
 	}
-	decimalPlaces += changeNum
-	val, _ = decimal.NewFromFloat(val).Round(int32(decimalPlaces)).Float64()
+	val, _ = decimal.NewFromFloat(val).Round(int32(pointNum)).Float64()
 	newStr = fmt.Sprintf("%v", val)
 	if numberType == "percent" {
 		newStr += "%"