Example #1
0
        protected override Field CreateEntity()
        {
            Table       table = _tableElement.Entity;
            ProductRule prod  = table.ProductRule;

            _entity               = new Field(table, _data.GetAttribute("name"));
            _entity.ColIndex      = ParseUtil.ParseColumnIndex(_data.GetAttribute("colIndex"), -1);
            _entity.Type          = ParseUtil.ParseEnum <FieldType>(_data.GetAttribute("type"), FieldType.Unknown);
            _entity.Format        = _data.GetAttribute("format");
            _entity.CommentColumn = _data.GetAttribute("annnotationField");
            _entity.RefColumn     = _data.GetAttribute("refField");
            _entity.LinkType      = _data.GetAttribute("linkType");
            string tmpStr = _data.GetAttribute("dropDownListSource");

            if (!string.IsNullOrEmpty(tmpStr))
            {
                Source tmpSource = prod.GetSource(tmpStr);

                /**
                 * dropDownListSource数据源要么引用预定义的DataList,要么指定了DataTable.Field;否则将被忽略
                 */
                if (tmpSource != null && tmpSource is ListSource)
                {
                    _entity.DropDownListSource = tmpSource as ListSource;
                }
                else if (tmpSource == null && tmpStr.Contains('.'))
                {
                    tmpSource = new ListSource(tmpStr.Split('.')[0], tmpStr.Split('.')[1]);
                    _entity.DropDownListSource = tmpSource as ListSource;
                    prod.RegistSource(tmpSource);
                }
            }
            _entity.Spannable = ParseUtil.ParseBoolean(_data.GetAttribute("spannable"), false);
            _entity.ColSpan   = ParseUtil.ParseInt(_data.GetAttribute("colspan"), 1);
            _entity.SumField  = ParseUtil.ParseBoolean(_data.GetAttribute("sumfield"), false);
            _entity.EmptyFill = _data.GetAttribute("emptyFill");
            return(_entity);
        }
Example #2
0
        protected override Table CreateEntity()
        {
            BaseEntity  container = _upperElement.CurrentEntity;
            ProductRule prodRule  = container.ProductRule;

            Location tmpLocation = new Location(_data.GetAttribute("location"));

            _entity = new Table(prodRule, container, tmpLocation);
            string tmpStr = _data.GetAttribute("source");

            if (!string.IsNullOrEmpty(tmpStr))
            {
                _entity.SourceName = tmpStr;
                //只要不是动态解析的数据源,Source不能为空
                if ((container is Sheet && !(container as Sheet).IsDynamic) || !DynamicSource.NeedDynamicParse(tmpStr))
                {
                    //_entity.Source = prodRule.RegistSource(tmpStr);
                    prodRule.RegistSource(tmpStr);
                }
            }
            _entity.RowNumIndex   = ParseUtil.ParseColumnIndex(_data.GetAttribute("rowNumIndex"), -1);
            _entity.CopyFill      = ParseUtil.ParseBoolean(_data.GetAttribute("copyFill"), true);
            _entity.SumLocation   = ParseUtil.ParseEnum <LocationPolicy>(_data.GetAttribute("sumLocation"), LocationPolicy.Undefined);
            _entity.SumOffset     = ParseUtil.ParseInt(_data.GetAttribute("sumOffset"), _entity.SumLocation == LocationPolicy.Undefined || _entity.SumLocation == LocationPolicy.Absolute ? -1 : 0);
            _entity.AutoFitHeight = ParseUtil.ParseBoolean(_data.GetAttribute("autoFitHeight"), false);
            int groupLevel = ParseUtil.ParseInt(_data.GetAttribute("groupLevel"), 0);

            if (groupLevel > 0)
            {
                tmpStr = _data.GetAttribute("groupNumShow");
                if (!string.IsNullOrEmpty(tmpStr))
                {
                    bool[]   shows = new bool[groupLevel];
                    string[] bools = tmpStr.Split(',');

                    for (int i = 0; i < bools.Length && i < shows.Length; i++)
                    {
                        if (bool.Parse(bools[i]))
                        {
                            shows[i] = true;
                        }
                    }
                    _entity.SetGroup(shows);
                }
            }

            _entity.AdjustSumOffset();

            #region Field重复出现的处理
            List <Field> fieldlist = new List <Field>();
            tmpStr = _data.GetAttribute("fields");
            if (!string.IsNullOrEmpty(tmpStr))
            {
                string[] fieldArray = tmpStr.Split(',');
                foreach (var fieldname in fieldArray)
                {
                    fieldlist.Add(new Field(_entity, fieldname));
                }
            }
            _entity.AddFields(fieldlist);

            //子结点
            parseField(_upperElement.ProductRuleElement.QuerySubNodes("Field", _data));

            #endregion Field重复出现的处理

            // 行号处理
            parseRowNum(_upperElement.ProductRuleElement.QuerySubNodes("RowNum", _data));

            //区域计算:计算行号、字段的列位置,以及Table填充列范围
            _entity.CalculateArea();

            //汇总列:在确定字段位置之后处理
            tmpStr = _data.GetAttribute("sumColumns");
            if (!string.IsNullOrEmpty(tmpStr))
            {
                string[] columns = tmpStr.Split(',');
                _entity.AddSumColumns(columns);
            }
            return(_entity);
        }