Exemplo n.º 1
0
 private void _CheckForAndHandleExcelError(ExcelDataProvider.ICellInfo cell, ParsingContext context)
 {
     if (context.Scopes.Current.IsSubtotal)
     {
         CheckForAndHandleExcelError(cell);
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// If the supplied <paramref name="cell"/> contains an Excel error
 /// an <see cref="ExcelErrorValueException"/> with that errorcode will be thrown
 /// </summary>
 /// <param name="cell"></param>
 protected void CheckForAndHandleExcelError(ExcelDataProvider.ICellInfo cell)
 {
     if (cell.IsExcelError)
     {
         throw (new ExcelErrorValueException(ExcelErrorValue.Parse(cell.Value.ToString())));
     }
 }
Exemplo n.º 3
0
 protected bool ShouldIgnore(ExcelDataProvider.ICellInfo c, ParsingContext context)
 {
     if (CellStateHelper.ShouldIgnore(IgnoreHiddenValues, c, context))
     {
         return(true);
     }
     if (IgnoreErrors && c.IsExcelError)
     {
         return(true);
     }
     return(false);
 }
Exemplo n.º 4
0
        private static bool IsSubTotal(ExcelDataProvider.ICellInfo c)
        {
            var tokens = c.Tokens;

            if (tokens == null)
            {
                return(false);
            }
            return(c.Tokens.Any(token =>
                                token.TokenType == LexicalAnalysis.TokenType.Function &&
                                token.Value.Equals("SUBTOTAL", StringComparisonEx.InvariantCultureIgnoreCase)
                                ));
        }
Exemplo n.º 5
0
        private static bool IsSubTotal(ExcelDataProvider.ICellInfo c)
        {
            var tokens = c.Tokens;

            if (tokens == null)
            {
                return(false);
            }
            return(c.Tokens.Any(token =>
                                token.TokenTypeIsSet(LexicalAnalysis.TokenType.Function) &&
                                (token.Value.Equals("SUBTOTAL", StringComparison.OrdinalIgnoreCase) || token.Value.Equals("AGGREGATE", StringComparison.OrdinalIgnoreCase))
                                ));
        }
Exemplo n.º 6
0
        private static bool IsSubTotal(ExcelDataProvider.ICellInfo c, ParsingContext context)
        {
            IEnumerable <Token> tokens = c.Tokens;

            if (tokens == null)
            {
                if (string.IsNullOrEmpty(c.Formula))
                {
                    return(false);
                }
                else
                {
                    tokens = context.Parser.Lexer.Tokenize(c.Formula);
                }
            }
            return(tokens.Any(token =>
                              token.TokenType == TokenType.Function &&
                              token.Value.Equals("SUBTOTAL", StringComparison.InvariantCultureIgnoreCase)
                              ));
        }
 protected bool ShouldIgnore(ExcelDataProvider.ICellInfo c, ParsingContext context)
 {
     return(CellStateHelper.ShouldIgnore(IgnoreHiddenValues, c, context));
 }
Exemplo n.º 8
0
 internal static bool ShouldIgnore(bool ignoreHiddenValues, ExcelDataProvider.ICellInfo c, ParsingContext context)
 {
     return((ignoreHiddenValues && c.IsHiddenRow) || (context.Scopes.Current.IsSubtotal && IsSubTotal(c)));
 }
Exemplo n.º 9
0
        /// <summary>
        ///  This is used by the Stdev and Var functions to parse the values it receives from a cell range or refreence.
        /// </summary>
        /// <param name="IgnoreHiddenValues">This controls wether you should skip Hidden Values or not.</param>
        /// <param name="valueToParse">This is the value that will be parsed.</param>
        /// <param name="context">Unused, this is information about where the function is being executed.</param>
        /// <param name="includeLogicals">A flag to control wether you should parse logicals or not.</param>
        /// <param name="parsedValue">This out value is the parse value in double form.</param>
        /// <param name="theInputContainedOnlyStrings">This bool flag shows if only string inputs were given.</param>
        /// <returns>Returns true if the parseing succeded and false if it fails.</returns>
        public static bool TryToParseValuesFromInputArgumentByRefrenceOrRange(bool IgnoreHiddenValues, ExcelDataProvider.ICellInfo valueToParse, ParsingContext context, bool includeLogicals, out double parsedValue, out bool theInputContainedOnlyStrings)
        {
            var shouldIgnore = CellStateHelper.ShouldIgnore(IgnoreHiddenValues, valueToParse, context);
            var isNumeric    = ConvertUtil.IsNumeric(valueToParse.Value);
            var isABoolean   = valueToParse.Value is bool;

            if (!shouldIgnore && isNumeric && !isABoolean)
            {
                parsedValue = valueToParse.ValueDouble;
                theInputContainedOnlyStrings = false;
                return(true);
            }
            if (includeLogicals)
            {
                if (isABoolean)
                {
                    if ((bool)valueToParse.Value == true)
                    {
                        parsedValue = 1;
                    }
                    else
                    {
                        parsedValue = 0;
                    }
                    theInputContainedOnlyStrings = false;
                    return(true);
                }
                if (ConvertUtil.TryParseObjectToDecimal(valueToParse.ValueDouble, out double numericValue))
                {
                    parsedValue = numericValue;
                    theInputContainedOnlyStrings = false;
                    return(true);
                }
                parsedValue = 0.0;
                theInputContainedOnlyStrings = false;
                return(false);
            }
            else
            {
                if (isABoolean)
                {
                    parsedValue = valueToParse.ValueDoubleLogical;
                    theInputContainedOnlyStrings = false;
                    return(false);
                }
                if (ConvertUtil.TryParseObjectToDecimal(valueToParse.ValueDouble, out double numericValue))
                {
                    parsedValue = numericValue;
                    theInputContainedOnlyStrings = false;
                    return(false);
                }
                parsedValue = 0.0;
                theInputContainedOnlyStrings = false;
                return(false);
            }
        }