Exemplo n.º 1
0
        /// <summary>
        /// Get the "top10" rule type according to the follwoing attributes:
        /// "Bottom" and "Percent"
        ///
        /// @Bottom = "1" and @Percent = "0"/null       == Bottom
        /// @Bottom = "1" and @Percent = "1"            == BottomPercent
        /// @Bottom = "0"/null and @Percent = "0"/null  == Top
        /// @Bottom = "0"/null and @Percent = "1"       == TopPercent
        /// /// </summary>
        /// <returns>Top, TopPercent, Bottom or BottomPercent</returns>
        public static eExcelConditionalFormattingRuleType GetTop10Type(
            XmlNode topNode,
            XmlNamespaceManager nameSpaceManager)
        {
            // Get @Bottom attribute
            bool?isBottom = ExcelConditionalFormattingHelper.GetAttributeBoolNullable(
                topNode,
                ExcelConditionalFormattingConstants.Attributes.Bottom);

            // Get @Percent attribute
            bool?isPercent = ExcelConditionalFormattingHelper.GetAttributeBoolNullable(
                topNode,
                ExcelConditionalFormattingConstants.Attributes.Percent);

            if (isBottom == true)
            {
                if (isPercent == true)
                {
                    // @Bottom = "1" and @Percent = "1" == BottomPercent
                    return(eExcelConditionalFormattingRuleType.BottomPercent);
                }

                // @Bottom = "1" and @Percent = "0"/null == Bottom
                return(eExcelConditionalFormattingRuleType.Bottom);
            }

            if (isPercent == true)
            {
                // @Bottom = "0"/null and @Percent = "1" == TopPercent
                return(eExcelConditionalFormattingRuleType.TopPercent);
            }

            // @Bottom = "0"/null and @Percent = "0"/null == Top
            return(eExcelConditionalFormattingRuleType.Top);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Get the "aboveAverage" rule type according to the follwoing attributes:
        /// "AboveAverage", "EqualAverage" and "StdDev".
        ///
        /// @StdDev greater than "0"                              == AboveStdDev
        /// @StdDev less than "0"                                 == BelowStdDev
        /// @AboveAverage = "1"/null and @EqualAverage = "0"/null == AboveAverage
        /// @AboveAverage = "1"/null and @EqualAverage = "1"      == AboveOrEqualAverage
        /// @AboveAverage = "0" and @EqualAverage = "0"/null      == BelowAverage
        /// @AboveAverage = "0" and @EqualAverage = "1"           == BelowOrEqualAverage
        /// /// </summary>
        /// <returns>AboveAverage, AboveOrEqualAverage, BelowAverage or BelowOrEqualAverage</returns>
        internal static eExcelConditionalFormattingRuleType GetAboveAverageType(
            XmlNode topNode,
            XmlNamespaceManager nameSpaceManager)
        {
            // Get @StdDev attribute
            int?stdDev = ExcelConditionalFormattingHelper.GetAttributeIntNullable(
                topNode,
                ExcelConditionalFormattingConstants.Attributes.StdDev);

            if (stdDev > 0)
            {
                // @StdDev > "0" --> AboveStdDev
                return(eExcelConditionalFormattingRuleType.AboveStdDev);
            }

            if (stdDev < 0)
            {
                // @StdDev < "0" --> BelowStdDev
                return(eExcelConditionalFormattingRuleType.BelowStdDev);
            }

            // Get @AboveAverage attribute
            bool?isAboveAverage = ExcelConditionalFormattingHelper.GetAttributeBoolNullable(
                topNode,
                ExcelConditionalFormattingConstants.Attributes.AboveAverage);

            // Get @EqualAverage attribute
            bool?isEqualAverage = ExcelConditionalFormattingHelper.GetAttributeBoolNullable(
                topNode,
                ExcelConditionalFormattingConstants.Attributes.EqualAverage);

            if ((isAboveAverage == null) || (isAboveAverage == true))
            {
                if (isEqualAverage == true)
                {
                    // @AboveAverage = "1"/null and @EqualAverage = "1" == AboveOrEqualAverage
                    return(eExcelConditionalFormattingRuleType.AboveOrEqualAverage);
                }

                // @AboveAverage = "1"/null and @EqualAverage = "0"/null == AboveAverage
                return(eExcelConditionalFormattingRuleType.AboveAverage);
            }

            if (isEqualAverage == true)
            {
                // @AboveAverage = "0" and @EqualAverage = "1" == BelowOrEqualAverage
                return(eExcelConditionalFormattingRuleType.BelowOrEqualAverage);
            }

            // @AboveAverage = "0" and @EqualAverage = "0"/null == BelowAverage
            return(eExcelConditionalFormattingRuleType.BelowAverage);
        }