|
@@ -1276,6 +1276,14 @@ func handleMixCellShowStyle(showStyleList []string, calculateCellMap map[string]
|
|
|
styleConf.Pn = 0
|
|
|
} else if styleConf.Decimal != nil {
|
|
|
cell.ShowFormatValue = roundNumber(cell.ShowValue, *styleConf.Decimal, hasPercent)
|
|
|
+ } else {
|
|
|
+ if hasPercent {
|
|
|
+ numDecimal, _ := decimal.NewFromString(cell.ShowValue)
|
|
|
+ tmpStr := numDecimal.Mul(decimal.NewFromInt(100)).String()
|
|
|
+ cell.ShowFormatValue = tmpStr + "%"
|
|
|
+ } else {
|
|
|
+ cell.ShowFormatValue = cell.ShowValue
|
|
|
+ }
|
|
|
}
|
|
|
} else if styleConf.Decimal != nil {
|
|
|
cell.ShowFormatValue = roundNumber(cell.ShowValue, *styleConf.Decimal, hasPercent)
|
|
@@ -1308,11 +1316,11 @@ func getDecimalLen(str string, isPercent bool) (decimalPlaces int) {
|
|
|
}
|
|
|
|
|
|
func roundNumber(num string, decimalPlaces int, hasPercent bool) string {
|
|
|
- numFloat, _ := strconv.ParseFloat(num, 64)
|
|
|
+ numDecimal, _ := decimal.NewFromString(num)
|
|
|
if hasPercent {
|
|
|
- numFloat = numFloat * 100
|
|
|
+ numDecimal = numDecimal.Mul(decimal.NewFromInt(100))
|
|
|
}
|
|
|
- numFloat, _ = decimal.NewFromFloat(numFloat).Round(int32(decimalPlaces)).Float64()
|
|
|
+ numFloat, _ := numDecimal.Round(int32(decimalPlaces)).Float64()
|
|
|
numStr := strconv.FormatFloat(numFloat, 'f', decimalPlaces, 64)
|
|
|
if hasPercent {
|
|
|
numStr += "%"
|