public RptText(RptPart p_owner) : base(p_owner) { _data.AddCell <string>("val"); _data.AddCell <bool>("hidetopdup"); _data.AddCell <bool>("hideleftdup"); _data.AddCell <bool>("autoheight"); _data.AddCell <bool>("handleclick"); _data.AddCell <bool>("wordwrap"); _data.AddCell("fontfamily", DefaultFontName); _data.AddCell("fontsize", DefaultFontSize); _data.AddCell <bool>("bold"); _data.AddCell <bool>("italic"); _data.AddCell <bool>("underline"); _data.AddCell <bool>("strikeout"); _data.AddCell("foreground", _defaultForeground); _data.AddCell("background", _defaultBackground); _data.AddCell("horalign", _defaultAlign); _data.AddCell("veralign", _defaultAlign); _data.AddCell("margin", 0); _data.AddCell("lbc", _defaultForeground); _data.AddCell("tbc", _defaultForeground); _data.AddCell("rbc", _defaultForeground); _data.AddCell("bbc", _defaultForeground); _data.AddCell("lbs", _defaultBorder); _data.AddCell("tbs", _defaultBorder); _data.AddCell("rbs", _defaultBorder); _data.AddCell("bbs", _defaultBorder); }
public RptChart(RptPart p_owner) : base(p_owner) { // 图表类型 _data.AddCell("type", "Column"); // 图例是否可见 _data.AddCell("showlegend", true); // 图例标题 _data.AddCell <string>("legtitle"); // 图例位置 _data.AddCell("legpos", "Right"); // 布局方向 _data.AddCell("legorientation", "Vertical"); // 标题 _data.AddCell <string>("title"); // X轴标题 _data.AddCell <string>("titlex"); // Y轴标题 _data.AddCell <string>("titley"); // 数据源名称 _data.AddCell <string>("tbl"); // 系列字段名 _data.AddCell <string>("fieldseries"); // x轴字段名 _data.AddCell <string>("fieldx"); // y轴字段名 _data.AddCell <string>("fieldy"); // 扩展字段 _data.AddCell <string>("fieldz"); }
/// <summary> /// 构造方法 /// </summary> /// <param name="p_owner"></param> public RptItem(RptPart p_owner) { _part = p_owner; _data.AddCell("row", 0); _data.AddCell("col", 0); _data.AddCell("rowspan", 1); _data.AddCell("colspan", 1); }
public RptMatrix(RptPart p_owner) : base(p_owner) { Rows = new List <RptMtxRow>(); _data.AddCell <string>("tbl"); _data.AddCell <bool>("hiderowheader"); _data.AddCell <bool>("hidecolheader"); _data.AddCell <bool>("repeatrowheader"); _data.AddCell <bool>("repeatcolheader"); _data.AddCell <string>("rowsort"); _data.AddCell <string>("colsort"); }
/// <summary> /// 加载xml /// </summary> /// <param name="p_reader"></param> public void ReadXml(XmlReader p_reader) { if (p_reader == null || p_reader.IsEmptyElement || p_reader.Name != "Rpt") { throw new Exception("加载报表模板根节点时出错!"); } // 报表列宽 Cols = RptPart.SplitSize(p_reader.GetAttribute("cols")); // 模板内容 p_reader.Read(); while (p_reader.NodeType != XmlNodeType.None) { if (p_reader.NodeType == XmlNodeType.EndElement && p_reader.Name == "Rpt") { break; } switch (p_reader.Name) { case "Params": Params.ReadXml(p_reader); break; case "Data": Data.ReadXml(p_reader); break; case "Page": PageSetting.ReadXml(p_reader); break; case "Header": Header.ReadXml(p_reader); break; case "Body": Body.ReadXml(p_reader); break; case "Footer": Footer.ReadXml(p_reader); break; case "View": ViewSetting.ReadXml(p_reader); break; } } }
/// <summary> /// 触发报表项增删事件 /// </summary> /// <param name="p_container"></param> /// <param name="e"></param> public void OnItemsChanged(RptPart p_container, NotifyCollectionChangedEventArgs e) { if (ItemsChanged != null) { ItemsChanged(p_container, e); if (e.Action == NotifyCollectionChangedAction.Add) { for (int i = 0; i < e.NewItems.Count; i++) { (e.NewItems[i] as RptItem).Data.AcceptChanges(); } } } }
public RptTable(RptPart p_owner) : base(p_owner) { // 数据源名称 _data.AddCell <string>("tbl"); // 在每页重复表头表尾 _data.AddCell <bool>("repeatheader"); _data.AddCell <bool>("repeatfooter"); // 最少行数 _data.AddCell("minrowcount", 0); // 多列显示 _data.AddCell("rowbreakcount", 0); _data.AddCell("colbreakcount", 1); }
/// <summary> /// 序列化xml /// </summary> /// <param name="p_writer"></param> public void WriteXml(XmlWriter p_writer) { p_writer.WriteStartElement("Rpt"); p_writer.WriteAttributeString("cols", RptPart.MergeSize(Cols)); Params.WriteXml(p_writer); Data.WriteXml(p_writer); PageSetting.WriteXml(p_writer); Header.WriteXml(p_writer); Body.WriteXml(p_writer); Footer.WriteXml(p_writer); ViewSetting.WriteXml(p_writer); p_writer.WriteEndElement(); }
public override object Execute(object p_args) { InsertCmdArgs args = (InsertCmdArgs)p_args; RptMatrix mat = args.RptItem as RptMatrix; RptPart con = mat.Part; // 是通过重做来执行的,直接返回对象。 if (mat.RowHeader != null || mat.ColHeader != null) { con.Items.Add(mat); return(mat); } CellRange range = args.CellRange; mat.Row = range.Row; mat.Col = range.Column; mat.RowSpan = range.RowCount; mat.ColSpan = range.ColumnCount; mat.Corner = new RptMtxCorner(mat); RptMtxRowHeader rowheader = new RptMtxRowHeader(mat); mat.RowHeader = rowheader; RptMtxLevel level2 = new RptMtxLevel(rowheader); level2.Item.Val = "level2"; rowheader.Levels.Add(level2); RptMtxColHeader colheader = new RptMtxColHeader(mat); mat.ColHeader = colheader; RptMtxLevel level1 = new RptMtxLevel(colheader); level1.Item.Val = "level1"; colheader.Levels.Add(level1); RptMtxRow row = new RptMtxRow(mat); row.Cells.Add(new RptText(row) { Val = "cell0" }); mat.Rows.Add(row); con.Items.Add(mat); return(mat); }
/// <summary> /// 获取内部行高 /// </summary> /// <param name="p_offset">偏移位置</param> /// <returns></returns> public double GetRowHeight(int p_offset) { RptPart part = Part; if (part.PartType == RptPartType.Header || part.PartType == RptPartType.Footer) { return(part.Height); } int index = Row + p_offset; double[] rows = Root.Body.Rows; if (rows == null || index >= rows.Length) { throw new Exception("位置超出行数!"); } return(rows[index]); }
/// <summary> /// 判定某区域是否有控件 或 是否有指定对象之外的控件 /// </summary> /// <param name="p_part"></param> /// <param name="p_range"></param> /// <param name="p_item"></param> /// <returns></returns> public static bool ValidEmptyRange(RptPart p_part, Dt.Cells.Data.CellRange p_range, RptItem p_item = null) { if (p_part == null || p_range == null) { return(false); } if (p_item == null) { return((from item in (IEnumerable <RptItem>)p_part.Items where p_range.Intersects(item.Row, item.Col, item.RowSpan, item.ColSpan) select item).Any()); } else { return((from item in (IEnumerable <RptItem>)p_part.Items where p_item != item && p_range.Intersects(item.Row, item.Col, item.RowSpan, item.ColSpan) select item).Any()); } }
public override object Execute(object p_args) { InsertCmdArgs args = (InsertCmdArgs)p_args; RptTable tbl = args.RptItem as RptTable; RptPart con = tbl.Part; //通过重做重新加载table,不用处理 if (tbl.Header != null || tbl.Body != null || tbl.Footer != null) { con.Items.Add(tbl); return(tbl); } CellRange range = args.CellRange; tbl.Row = range.Row; tbl.Col = range.Column; tbl.RowSpan = range.RowCount; tbl.ColSpan = range.ColumnCount; RptTblPartRow tblRow; switch (tbl.RowSpan) { case 1: tbl.Body = new RptTblRow(tbl); tblRow = new RptTblPartRow(tbl.Body); tbl.Body.Rows.Add(tblRow); BuildCells(tblRow, tbl.ColSpan); break; case 2: tbl.Header = new RptTblHeader(tbl); tblRow = new RptTblPartRow(tbl.Header); tbl.Header.Rows.Add(tblRow); BuildCells(tblRow, tbl.ColSpan); tbl.Body = new RptTblRow(tbl); tblRow = new RptTblPartRow(tbl.Body); tbl.Body.Rows.Add(tblRow); BuildCells(tblRow, tbl.ColSpan); break; default: tbl.Header = new RptTblHeader(tbl); tblRow = new RptTblPartRow(tbl.Header); tbl.Header.Rows.Add(tblRow); BuildCells(tblRow, tbl.ColSpan); tbl.Body = new RptTblRow(tbl); for (int i = 0; i < tbl.RowSpan - 2; i++) { tblRow = new RptTblPartRow(tbl.Body); tbl.Body.Rows.Add(tblRow); BuildCells(tblRow, tbl.ColSpan); } tbl.Footer = new RptTblFooter(tbl); tblRow = new RptTblPartRow(tbl.Footer); tbl.Footer.Rows.Add(tblRow); BuildCells(tblRow, tbl.ColSpan); break; } con.Items.Add(tbl); return(tbl); }
/// <summary> /// /// </summary> public RptHeaderInst(RptPart p_item) { _item = p_item; _children = new List <RptTextInst>(); }
/// <summary> /// 更新选择区域 /// </summary> public void UpdateSelection() { CellRange range; Excel excel = _owner.Excel; Worksheet sheet = excel.ActiveSheet; RptItem curItem = null; RptPart container = _owner.GetContainer(); excel.DecorationRange = null; // 无选择及选择整行整列 : 返回。无选择可能是选中浮动对象造成的,现不在此处处理。 if (sheet.Selections.Count == 0 || (range = sheet.Selections[0]).Row == -1 || range.Column == -1) { _owner.ClearForms(); return; } // 三种情况,在已有对象内部、相交、空白区域 foreach (RptItem item in container.Items) { // 选择区域在报表项内 if (item.Contains(range)) { curItem = item; break; } // 相交,无操作,返回 if (range.Intersects(item.Row, item.Col, item.RowSpan, item.ColSpan)) { _owner.ClearForms(); return; } } if (curItem == null) { // 在空白区域 if (container.PartType == RptPartType.Body) { if (_menuBlank == null) { _menuBlank = new BlankAreaMenu(_owner); } ShowMenu(_menuBlank, range); } else { // 页眉页脚菜单 if (_menuHeader == null) { _menuHeader = new HeaderFooterMenu(_owner); } ShowMenu(_menuHeader, range); } _owner.ClearForms(); } else { // 在对象内部 excel.DecorationRange = new CellRange(curItem.Row, curItem.Col, curItem.RowSpan, curItem.ColSpan); _owner.LoadForms(curItem, range); } }
/// <summary> /// /// </summary> public RptBodyInst(RptPart p_item) { _item = p_item; _children = new List <RptItemInst>(); }