xyxie 1 year ago
parent
commit
7b0a3f1e98
1 changed files with 9 additions and 0 deletions
  1. 9 0
      services/data/excel/mixed_table.go

+ 9 - 0
services/data/excel/mixed_table.go

@@ -1213,3 +1213,12 @@ func handleMixCellShowStyle(showStyleList []string, calculateCellMap map[string]
 	}
 	return
 }
+func CountDecimalPlaces(num float64) int {
+	str := fmt.Sprintf("%f", num)       // 将浮点数转换为字符串
+	dotIndex := strings.Index(str, ".") // 查找小数点的位置
+	if dotIndex == -1 {
+		return 0 // 没有小数点,返回0
+	}
+	decimalPlaces := len(str) - dotIndex - 1 // 计算小数位数
+	return decimalPlaces
+}