Example #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:Dt.Cells.Data.NumberFormatDigital" /> class.
        /// </summary>
        /// <param name="format">The format.</param>
        /// <param name="partLocaleID">The part locale ID.</param>
        /// <param name="dbNumberFormatPart">The number format part.</param>
        /// <param name="culture">The culture.</param>
        public NumberFormatDigital(string format, object partLocaleID, object dbNumberFormatPart, CultureInfo culture) : base(partLocaleID, dbNumberFormatPart, culture)
        {
            this.excelFormatString = string.Empty;
            string s = NumberFormatBase.TrimNotSupportSymbol(format);

            this.fullFormatString  = DefaultTokens.Filter(s, DefaultTokens.LeftSquareBracket, DefaultTokens.RightSquareBracket);
            this.excelFormatString = s;
            if (partLocaleID != null)
            {
                string str2 = s;
                s = DefaultTokens.ReplaceKeyword(str2, base.PartLocaleID.OriginalToken, base.PartLocaleID.CurrencySymbol);
            }
            if (base.PartDBNumberFormat != null)
            {
                this.excelFormatString = DefaultTokens.ReplaceKeyword(this.excelFormatString, base.PartDBNumberFormat.OriginalToken, base.PartDBNumberFormat.ToString());
            }
            s = DefaultTokens.Filter(s, DefaultTokens.LeftSquareBracket, DefaultTokens.RightSquareBracket);
            if (s.IndexOf(DefaultTokens.SolidusSign) > -1)
            {
                s = s.Replace(DefaultTokens.QuestionMark, DefaultTokens.Zero);
                string[] strArray = DefaultTokens.Split(s, DefaultTokens.SolidusSign);
                if ((strArray != null) && (strArray.Length == 2))
                {
                    this.fractionDenominatorFormat = strArray[1];
                    string[] integerAndNumeratorParts = this.GetIntegerAndNumeratorParts(strArray[0]);
                    if ((integerAndNumeratorParts != null) && (integerAndNumeratorParts.Length == 3))
                    {
                        this.fractionIntegerFormat   = integerAndNumeratorParts[0];
                        this.constString             = integerAndNumeratorParts[1];
                        this.fractionNumeratorFormat = integerAndNumeratorParts[2];
                    }
                }
            }
            this.numberFormatString = s;
        }
Example #2
0
        /// <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;
        }