Exemplo n.º 1
0
        public void WriteConditionalFormattingDataBar(DataBar dataBar, out CT_DataBar cfDataBar)
        {
            if (dataBar == null)
            {
                cfDataBar = null;
                return;
            }
            List <CT_Cfvo> ct_cfvo_list = new List <CT_Cfvo>();

            foreach (var ct_cfvo in dataBar.CFVOList)
            {
                ct_cfvo_list.Add(new CT_Cfvo
                {
                    val  = ct_cfvo.Value,
                    type = (ST_CfvoType)ct_cfvo.Type //1-1
                });
            }
            cfDataBar = new CT_DataBar
            {
                cfvo  = ct_cfvo_list.ToArray(),
                color = ConvertColor(dataBar.Color)
            };
        }
        public XSSFDataBarFormatting CreateDataBarFormatting(XSSFColor color)
        {
            // Is it already there?
            if (_cfRule.IsSetDataBar() && _cfRule.type == ST_CfType.dataBar)
            {
                return(DataBarFormatting as XSSFDataBarFormatting);
            }

            // Mark it as being a Data Bar
            _cfRule.type = ST_CfType.dataBar;

            // Ensure the right element
            CT_DataBar bar = null;

            if (_cfRule.IsSetDataBar())
            {
                bar = _cfRule.dataBar;
            }
            else
            {
                bar = _cfRule.AddNewDataBar();
            }
            // Set the color
            bar.color = (color.GetCTColor());

            // Add the default thresholds
            CT_Cfvo min = bar.AddNewCfvo();

            min.type = (ST_CfvoType)Enum.Parse(typeof(ST_CfvoType), RangeType.MIN.name);
            CT_Cfvo max = bar.AddNewCfvo();

            max.type = (ST_CfvoType)Enum.Parse(typeof(ST_CfvoType), RangeType.MAX.name);

            // Wrap and return
            return(new XSSFDataBarFormatting(bar));
        }
Exemplo n.º 3
0
        public void WriteConditionalFormattingRule(CFRule rule, string firstCell, out CT_CfRule cfRule)
        {
            ST_CfType     st_cftype     = (ST_CfType)rule.Type;
            CT_ColorScale ct_colorscale = null;
            CT_DataBar    ct_databar    = null;
            CT_IconSet    ct_iconset    = null;

            if (rule.Type == CFType.ColorScale)
            {
                WriteConditionalFormattingColorScale(rule.ColorScale, out ct_colorscale);
            }

            if (rule.Type == CFType.DataBar)
            {
                WriteConditionalFormattingDataBar(rule.DataBar, out ct_databar);
            }

            if (rule.Type == CFType.IconSet)
            {
                WriteConditionalFormattingIconSet(rule.IconSet, out ct_iconset);
            }

            if (CFRule.RequiresDxf(rule.Type))
            {
                List <string> formulas = new List <string>();

                if (!string.IsNullOrEmpty(rule.Formula1))
                {
                    formulas.Add(rule.Formula1);
                }

                if (!string.IsNullOrEmpty(rule.Formula2))
                {
                    formulas.Add(rule.Formula2);
                }

                if (!string.IsNullOrEmpty(rule.Formula3))
                {
                    formulas.Add(rule.Formula3);
                }

                cfRule = new CT_CfRule
                {
                    typeSpecified     = true,
                    type              = st_cftype,
                    priority          = rule.Priority,
                    formula           = formulas.ToArray(),
                    operatorSpecified = rule.Operator.HasValue,
                    @operator         = rule.Operator.HasValue ? (ST_ConditionalFormattingOperator)rule.Operator.Value : ST_ConditionalFormattingOperator.beginsWith,
                    text              = rule.Text,
                };
                cfRule = SetDxfStyle(cfRule, rule.Style);

                switch (rule.Type)
                {
                case CFType.Top10:
                    cfRule.percent       = rule.IsPercent;
                    cfRule.bottom        = rule.IsBottom;
                    cfRule.rankSpecified = rule.Rank.HasValue;
                    cfRule.rank          = (uint)rule.Rank.Value;
                    break;

                case CFType.AboveAverage:
                    cfRule.aboveAverage    = rule.IsAboveAverage;
                    cfRule.equalAverage    = rule.IsEqualAverage;
                    cfRule.stdDevSpecified = rule.IsStdDev;
                    cfRule.stdDev          = rule.StdDev;
                    break;

                case CFType.TimePeriod:
                    cfRule.timePeriodSpecified = true;
                    cfRule.timePeriod          = (ST_TimePeriod)rule.TimePeriod;
                    break;
                }
                return;
            }

            cfRule = new CT_CfRule
            {
                typeSpecified = true,
                type          = st_cftype,
                colorScale    = ct_colorscale,
                dataBar       = ct_databar,
                iconSet       = ct_iconset,
                priority      = rule.Priority
            };
        }
Exemplo n.º 4
0
 /*package*/
 public XSSFDataBarFormatting(CT_DataBar databar)
 {
     _databar = databar;
 }