用这个C#代码加千分位简单点
using System.Windows.Forms; using System.Text; using System.Collections.Generic; using System.Text.RegularExpressions; // Quicker将会调用的函数 public static void Exec(Quicker.Public.IStepContext context){ var oldValue = context.GetVarValue("context"); string tmp= oldValue as string; string[] strList=tmp.Split(new string[] { "\r\n" }, StringSplitOptions.None); for (int i = 0; i < strList.Length; i++) { string integerSub=""; string decimalSub=""; if(strList[i].IndexOf(".")>0) { integerSub=strList[i].Substring(0,strList[i].IndexOf(".")); decimalSub=strList[i].Substring(strList[i].IndexOf("."),strList[i].Length-strList[i].IndexOf(".")); } else { integerSub = strList[i]; } string result = ""; Regex regex = new Regex(@"((?<!^|\D)\d{3})",RegexOptions.RightToLeft); if(regex.IsMatch(integerSub)) { result = regex.Replace(integerSub,",$1"); } strList[i]=result+decimalSub; } context.SetVarValue("context", string.Join("\r\n",strList)); }
谢谢