Browse Source

fix:百分号进位

zqbao 6 months ago
parent
commit
0af8682f3f
1 changed files with 3 additions and 1 deletions
  1. 3 1
      services/data/excel/mixed_table.go

+ 3 - 1
services/data/excel/mixed_table.go

@@ -1264,8 +1264,10 @@ func getDecimalLen(str string, isPercent bool) (decimalPlaces int) {
 
 
 func roundNumber(num string, decimalPlaces int, hasPercent bool) string {
 func roundNumber(num string, decimalPlaces int, hasPercent bool) string {
 	numFloat, _ := strconv.ParseFloat(num, 64)
 	numFloat, _ := strconv.ParseFloat(num, 64)
+	if hasPercent {
+		numFloat = numFloat * 100
+	}
 	numFloat, _ = decimal.NewFromFloat(numFloat).Round(int32(decimalPlaces)).Float64()
 	numFloat, _ = decimal.NewFromFloat(numFloat).Round(int32(decimalPlaces)).Float64()
-
 	numStr := strconv.FormatFloat(numFloat, 'f', decimalPlaces, 64)
 	numStr := strconv.FormatFloat(numFloat, 'f', decimalPlaces, 64)
 	if hasPercent {
 	if hasPercent {
 		numStr += "%"
 		numStr += "%"