/// <summary> /// Initializes a new instance of the <see cref="T:Dt.Cells.Data.NumberFormatText" /> class. /// </summary> /// <param name="format">The format string</param> /// <param name="partLocaleID">The part locale ID.</param> /// <param name="dbNumberFormatPart">The db number format part.</param> /// <param name="culture">The culture.</param> internal NumberFormatText(string format, object partLocaleID, object dbNumberFormatPart, CultureInfo culture) : base(partLocaleID, dbNumberFormatPart, culture) { if (format == null) { throw new ArgumentNullException("format"); } string s = NumberFormatBase.TrimNotSupportSymbol(format, false); if (partLocaleID != null) { s = DefaultTokens.ReplaceKeyword(s, base.PartLocaleID.OriginalToken, base.PartLocaleID.CurrencySymbol); } this.excelFormatString = s; s = DefaultTokens.TrimEscape(DefaultTokens.Filter(s, DefaultTokens.LeftSquareBracket, DefaultTokens.RightSquareBracket)); this.formatString = s; }
/// <summary> /// Formats the specified value. /// </summary> /// <param name="obj">The object.</param> /// <returns> /// Returns the string of the formatted value. /// </returns> public override string Format(object obj) { string str = string.Empty; if (FormatConverter.IsNumber(obj)) { bool flag = (base.PartLocaleID == null) || base.PartLocaleID.AllowScience; double?nullable = FormatConverter.TryDouble(obj, true); if (!nullable.HasValue) { return(""); } double num = nullable.Value; if (((Math.Abs(num) <= 99999999999) || !flag) && ((Math.Abs(num) >= 1E-11) || (num == 0.0))) { return(this.DigitalFormat.Format(obj)); } return(this.ExponentialDigitalFormat.Format(obj)); } if (obj is string) { string newValue = FormatConverter.ToString(obj, true); string str3 = DefaultTokens.TrimEscape(this.FormatString.Replace("\"", "")); if (str3 != null) { newValue = str3.Replace("General", newValue); } return(newValue); } if (obj is bool) { bool flag2 = (bool)((bool)obj); str = flag2.ToString().ToUpper(); } return(str); }