소스 검색

fix:decimal小数位显示

zqbao 3 달 전
부모
커밋
08a2b14fbd
1개의 변경된 파일2개의 추가작업 그리고 1개의 파일을 삭제
  1. 2 1
      services/excel/lucky_sheet.go

+ 2 - 1
services/excel/lucky_sheet.go

@@ -1291,7 +1291,8 @@ func roundNumber(num string, decimalPlaces int, hasPercent bool) string {
 	if hasPercent {
 		numDecimal = numDecimal.Mul(decimal.NewFromInt(100))
 	}
-	numStr := numDecimal.Round(int32(decimalPlaces)).String()
+	numFloat, _ := numDecimal.Round(int32(decimalPlaces)).Float64()
+	numStr := strconv.FormatFloat(numFloat, 'f', decimalPlaces, 64)
 	if hasPercent {
 		numStr += "%"
 	}