コード例 #1
0
 public ExcelValue FIXED(List <ExcelValue> args, ExpressionScope scope)
 {
     if (args.ContainErrorValues())
     {
         return(ExcelValue.NA);
     }
     if (args.NotDecimal(0, null, out double num))
     {
         return(ExcelValue.VALUE);
     }
     if (args.NotInteger(1, 2, out int decimals))
     {
         return(ExcelValue.VALUE);
     }
     if (args.NotBoolean(2, false, out bool noComma))
     {
         return(ExcelValue.VALUE);
     }
     if (decimals < 0)
     {
         var factor = Math.Pow(10, -decimals);
         num      = Math.Round(num / factor, 0) * factor;
         decimals = 0;
     }
     return(new ExcelValue.DecimalValue(num, scope.OutLanguage,
                                        noComma ? ExpressionFormat.CreateFixedPoint(decimals) : ExpressionFormat.CreateNumeric(decimals)));
 }
コード例 #2
0
ファイル: ExcelValue.cs プロジェクト: pkokki/DocumentCreator
 internal override string ToString(Language language, ExpressionFormat info)
 {
     if (info != null)
     {
         return(language.ToString((double)InnerValue, info));
     }
     return(Text);
 }
コード例 #3
0
        public ValueFormat GetFormat(ExpressionFormat defaultFormat)
        {
            var format = Resolve();

            if (format == null && defaultFormat != null)
            {
                format = defaultFormat.Resolve();
            }
            return(format ?? TranslateExcelStandardFormat(0));
        }
コード例 #4
0
ファイル: ExcelValue.cs プロジェクト: pkokki/DocumentCreator
            internal override string ToString(Language language, ExpressionFormat info)
            {
                if (info == null)
                {
                    info = Format;
                }
                var date = FromDateSerial(Serial);

                if (date.HasValue)
                {
                    return(language.ToString(date.Value, info));
                }
                return(NA.ToString());
            }
コード例 #5
0
        public ExcelValue TEXT(List <ExcelValue> args, ExpressionScope scope)
        {
            if (args.NotText(1, null, scope.OutLanguage, out string format))
            {
                return(ExcelValue.NA);
            }
            var exprFormat = new ExpressionFormat(null, format, scope.OutLanguage.NumberFormat);

            //if (args[0] is ExcelValue.DateValue)
            //{
            //    var date = ((ExcelValue.DateValue)args[0]).Date;
            //    return new ExcelValue.TextValue(scope.OutLanguage.ToString(date, exprFormat), scope.OutLanguage);
            //}
            //else
            //{
            if (args.NotDecimal(0, null, out double value))
            {
                return(ExcelValue.NA);
            }
            return(new ExcelValue.TextValue(scope.OutLanguage.ToString(value, exprFormat), scope.OutLanguage));
            //}
        }
コード例 #6
0
ファイル: ExcelValue.cs プロジェクト: pkokki/DocumentCreator
 public DecimalValue(double value, Language language, ExpressionFormat format = null)
     : base(value, language.ToString(value, format), language)
 {
 }
コード例 #7
0
ファイル: ExcelValue.cs プロジェクト: pkokki/DocumentCreator
 public DateValue(double serial, Language language, ExpressionFormat format)
     : base(serial, language, ExpressionFormat.General)
 {
     Serial = serial;
     Format = format;
 }
コード例 #8
0
ファイル: ExcelValue.cs プロジェクト: pkokki/DocumentCreator
 internal override string ToString(Language language, ExpressionFormat info)
 {
     return(Text);
 }
コード例 #9
0
ファイル: ExcelValue.cs プロジェクト: pkokki/DocumentCreator
 internal abstract string ToString(Language language, ExpressionFormat info);
コード例 #10
0
ファイル: ExcelValue.cs プロジェクト: pkokki/DocumentCreator
        internal static ExcelValue CreateDateValue(int year, int month, int day, int hours, int minutes, int seconds, Language language, ExpressionFormat format)
        {
            var serial = ToDateSerial(year, month, day, hours, minutes, seconds);

            if (serial.HasValue)
            {
                return(new DateValue(serial.Value, language, format));
            }
            return(NA);
        }
コード例 #11
0
ファイル: ExcelValue.cs プロジェクト: pkokki/DocumentCreator
 internal static ExcelValue CreateDateValue(int year, int month, int day, Language language, ExpressionFormat format)
 {
     return(CreateDateValue(year, month, day, 0, 0, 0, language, format));
 }