|
@@ -1219,26 +1219,15 @@ func handleMixCellShowStyle(showStyleList []string, calculateCellMap map[string]
|
|
|
}
|
|
|
|
|
|
|
|
|
-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 += "%"
|