Просмотр исходного кода

fix:修复excel表中负百分数的bug

Roc 11 месяцев назад
Родитель
Сommit
09b694971c
1 измененных файлов с 2 добавлено и 3 удалено
  1. 2 3
      utils/common.go

+ 2 - 3
utils/common.go

@@ -2090,14 +2090,13 @@ func GetColorMap() map[int]string {
 // @return bool
 // @return bool
 // @return string
 // @return string
 func IsPercentage(input string) (bool, string) {
 func IsPercentage(input string) (bool, string) {
-	percentagePattern := `^(\d{1,2}(\.\d{1,2})?)%$`
+	percentagePattern := `^-?(\d{1,2}(\.\d{1,2})?)%$`
 	match, _ := regexp.MatchString(percentagePattern, input)
 	match, _ := regexp.MatchString(percentagePattern, input)
 
 
 	if match {
 	if match {
-		// 提取百分比值
 		re := regexp.MustCompile(percentagePattern)
 		re := regexp.MustCompile(percentagePattern)
 		match := re.FindStringSubmatch(input)
 		match := re.FindStringSubmatch(input)
-		return true, match[1]
+		return true, match[1] // 返回第一个捕获组的内容,即整个负数百分比数值
 	}
 	}
 
 
 	return false, ""
 	return false, ""