Example #1
0
        public static double[,] GetDoubleMatrix(object oMatrix)
        {
            object[,] objectMatrix = CheckIfValidObjectMatrix(oMatrix);

            var result = new double[objectMatrix.GetLength(0), objectMatrix.GetLength(1)];

            for (int rowIndex = objectMatrix.GetLowerBound(0); rowIndex <= objectMatrix.GetUpperBound(0); rowIndex++)
            {
                for (int colIndex = objectMatrix.GetLowerBound(1); colIndex <= objectMatrix.GetUpperBound(1); colIndex++)
                {
                    result[rowIndex, colIndex] = ExcelDataConverters.TryGetDoubleValue(objectMatrix[rowIndex, colIndex]);
                }
            }

            return(result);
        }
Example #2
0
        public static bool OptionalBool(object oBool, bool defaultBool)
        {
            if (oBool == null)
            {
                return(defaultBool);
            }
            if (oBool is ExcelMissing)
            {
                return(defaultBool);
            }
            if (oBool is string)
            {
                string sBool = (oBool as string).ToUpper();
                return(sBool == "WAHR" || sBool == "FALSE");
            }
            double dBool = ExcelDataConverters.TryGetDoubleValue(oBool);

            return(dBool != 0.0);
        }