public override object GetValue(QColumn col)
 {
     if (col.IsCount)
     {
         return string.Format("=SUBTOTAL(9,R[-{0}]C:R[-1]C)", sumCount);
     }
     return string.Empty;
 }
예제 #2
0
 public override object GetValue(QColumn col)
 {
     if (string.IsNullOrEmpty(col.Formula))
     {
         return base.GetValue(col);
     }
     return col.Formula;
 }
예제 #3
0
 public override void AddColumn(QColumn clumn)
 {
     clumn.Table = this.Table;
     clumn.SetCurIndex(this.columns.Count + 1);
     this.columns.Add(clumn);
 }
예제 #4
0
        /// <summary>
        /// 构建子列
        /// </summary>
        /// <param name="column"></param>
        /// <param name="xmlNodeList"></param>
        private void BuidChildColumn(QColumn column, XmlNodeList xmlNodeList)
        {
            if (xmlNodeList.Count > 0)
            {
                foreach (XmlNode node in xmlNodeList)
                {
                    if (node is XmlElement)
                    {
                        XmlElement element = node as XmlElement;
                        string widthText = element.GetAttribute("Width");
                        string fontSize = element.GetAttribute("FontSize");
                        string horizonAlign = element.GetAttribute("HorizonAlign").ToLower();
                        string contentHorizonAlign = element.GetAttribute("ContentHorizonAlign").ToLower();
                        QColumn childColumn = new QColumn
                        {
                            Name = element.GetAttribute("Name"),
                            Text = element.GetAttribute("Text"),
                            IsCount = string.IsNullOrEmpty(element.GetAttribute("IsCount")) ? false : Convert.ToBoolean(element.GetAttribute("IsCount")),
                            Formula = element.GetAttribute("Formula"),
                            NumberFormatLocal = element.GetAttribute("NumberFormatLocal"),
                            WrapText = element.GetAttribute("WrapText").ToLower() == "true",
                            BgColor = ExcelCommon.GetColorFromString(element.GetAttribute("BgColor")),
                            ContentBgColor = ExcelCommon.GetColorFromString(element.GetAttribute("ContentBgColor")),
                        };

                        if (!string.IsNullOrEmpty(horizonAlign))
                        {
                            childColumn.HorizonAlign = horizonAlign == "left" ? XlHAlign.xlHAlignLeft : XlHAlign.xlHAlignRight;
                        }
                        if (!string.IsNullOrEmpty(contentHorizonAlign))
                        {
                            childColumn.ContentHorizontalAlignment=contentHorizonAlign== "left" ? XlHAlign.xlHAlignLeft : XlHAlign.xlHAlignRight;
                        }
                        if (!string.IsNullOrEmpty(widthText))
                        {
                            try
                            {
                                childColumn.Width = Int32.Parse(widthText);
                            }
                            catch { };
                        }

                        if (!string.IsNullOrEmpty(fontSize))
                        {
                            try
                            {
                                childColumn.FontSize = Int32.Parse(fontSize);
                            }
                            catch { };
                        }
                        column.AddColumn(childColumn);
                        this.BuidChildColumn(childColumn, element.ChildNodes);
                    }
                }
            }
        }
예제 #5
0
 /// <summary>
 /// 获取单元格数据
 /// </summary>
 /// <param name="col"></param>
 /// <returns></returns>
 public virtual object GetValue(QColumn col)
 {
     if (Entity is DataRow)
     {
         DataRow dr = Entity as DataRow;
         try
         {
             return dr[col.Name];
         }
         catch
         {
             return string.Empty;
         }
     }
     else
     {
         Type type = Entity.GetType();
         PropertyInfo info = type.GetProperty(col.Name);
         if (info != null)
         {
             object obj = info.GetValue(Entity, null);
             if (obj == null)
             {
                 return string.Empty;
             }
             return obj.ToString();
         }
         return string.Empty;
     }
 }
예제 #6
0
 /// <summary>
 /// 递归得到当前列深度
 /// </summary>
 /// <param name="column"></param>
 private void GetCurDepth(QColumn column)
 {
     if (column.ParentColumn != null)
     {
         curDepth++;
         this.GetCurDepth(column.ParentColumn);
     }
 }
예제 #7
0
 /// <summary>
 /// 递归得到子列数
 /// </summary>
 /// <param name="clumn"></param>
 private void GetColumnsCount(QColumn clumn)
 {
     if (clumn.LeafColumns.Count == 0)
     {
         colCount++;
     }
     else
     {
         foreach (QColumn child in clumn.leafColumns)
             this.GetColumnsCount(child);
     }
 }
예제 #8
0
 /// <summary>
 /// 添加子列
 /// </summary>
 /// <param name="clumn"></param>
 public virtual void AddColumn(QColumn clumn)
 {
     clumn.curIndex = this.leafColumns.Count;
     this.leafColumns.Add(clumn);
     clumn.Table = this.Table;
     clumn.ParentColumn = this;
 }