Beispiel #1
0
        /// <summary>
        ///  克隆方法
        /// </summary>
        /// <returns></returns>
        public override RptItem Clone()
        {
            RptText newOne = new RptText(_part);

            newOne.Data.Copy(_data);
            return(newOne);
        }
Beispiel #2
0
        internal void LoadItem(RptText p_item, bool p_isGroup)
        {
            _txt     = p_item;
            _curRow  = p_item.Parent as RptTblPartRow;
            _part    = _curRow.Parent as RptTblPart;
            _table   = _part.Table;
            _fv.Data = _table.Data;

            UpdateHeaderFooterState();
            if (p_isGroup)
            {
                _fvGrp.Show("field");
                foreach (RptTblGroup grp in _table.Groups)
                {
                    if (grp.Header == _part || grp.Footer == _part)
                    {
                        _fvGrp.Data = grp.Data;
                        break;
                    }
                }
            }
            else
            {
                _fvGrp.Hide("field");
            }
        }
Beispiel #3
0
 public ValueChangedArgs(Cell p_cell, RptText p_rptText)
 {
     Cell    = p_cell;
     OldVal  = p_cell.OriginalVal;
     Val     = p_cell.Val;
     RptText = p_rptText;
 }
Beispiel #4
0
 internal void LoadItem(RptText p_item)
 {
     if (_item != p_item)
     {
         _item    = p_item;
         _fv.Data = _item.Data;
     }
 }
Beispiel #5
0
 public RptMtxSubtitle(RptItemBase p_parent)
 {
     _parent   = p_parent;
     Item      = new RptText(this);
     SubTitles = new List <RptMtxSubtitle>();
     // 所占行数/列数
     _data.AddCell("span", 1);
 }
Beispiel #6
0
 /// <summary>
 /// 加载RptText,一般用于加载报表顶级的RptText
 /// </summary>
 /// <param name="p_txt"></param>
 void LoadText(RptText p_txt)
 {
     Dt.Cells.Data.Cell cell = _owner.Excel.Sheets[(int)p_txt.Part.PartType].Cells[p_txt.Row, p_txt.Col];
     cell.RowSpan    = p_txt.RowSpan;
     cell.ColumnSpan = p_txt.ColSpan;
     cell.Value      = p_txt.Data.Str("val");
     p_txt.ApplyStyle(cell);
 }
Beispiel #7
0
        /// <summary>
        /// 为当前行添加新列
        /// </summary>
        /// <param name="p_matrix">矩阵</param>
        /// <param name="p_row">所属行</param>
        /// <param name="p_index">插入位置</param>
        /// <returns>新增列的集合</returns>
        IEnumerable <RptText> InsertNewCell(RptMatrix p_matrix, RptMtxRow p_row, int p_index)
        {
            RptText text = new RptText(p_row);

            text.Val = string.Format("cell{0}", p_matrix.GetCellsCount().ToString());
            p_row.Cells.Insert(p_index, text);
            yield return(text);
        }
Beispiel #8
0
        void OnInsertText(object sender, Mi e)
        {
            _owner.Excel.DecorationRange = null;
            CellRange range = _owner.Excel.ActiveSheet.Selections[0];
            var       item  = new RptText(_owner.GetContainer());

            _owner.Info.ExecuteCmd(RptCmds.InsertText, new InsertCmdArgs(item, range));
            _owner.UpdateSelection();
        }
Beispiel #9
0
 protected override void ReadChildXml(XmlReader p_reader)
 {
     if (p_reader.Name == "Text")
     {
         RptText cell = new RptText(this);
         cell.ReadXml(p_reader);
         Cells.Add(cell);
     }
 }
Beispiel #10
0
 public RptMtxLevel(RptMtxHeader p_header)
 {
     _header   = p_header;
     Item      = new RptText(this);
     SubTotals = new List <RptMtxSubtotal>();
     SubTitles = new List <RptMtxSubtitle>();
     // 对应字段名
     _data.AddCell <string>("field");
 }
Beispiel #11
0
        /// <summary>
        /// 输出图片
        /// </summary>
        /// <param name="p_img"></param>
        /// <param name="p_row"></param>
        /// <param name="p_col"></param>
        void RenderImage(RptTextInst p_img, int p_row, int p_col)
        {
            RptText item = p_img.Item as RptText;

            Kit.RunSync(() =>
            {
                Rect rc = _ws.GetRangeLocation(new CellRange(p_row, p_col, item.RowSpan, item.ColSpan));
                _ws.AddPicture(_ws.Pictures.Count.ToString(), new Uri(item.Val), rc.Left, rc.Top, rc.Width, rc.Height);
            });
        }
Beispiel #12
0
        public override async Task Build()
        {
            RptRootInst inst = _part.Inst;

            if (string.IsNullOrEmpty(Tbl))
            {
                return;
            }

            // 使用时再加载
            var rptData = await inst.Info.GetData(Tbl);

            if (rptData == null)
            {
                return;
            }

            RptMatrixInst matrixInst = new RptMatrixInst(this);

            matrixInst.RptData = rptData;
            ReBuildData(matrixInst.RptData.Data);
            inst.Body.AddChild(matrixInst);
            if (!HideRowHeader && !HideColHeader)
            {
                RptTextInst corner = new RptTextInst(Corner.Item);
                matrixInst.CornerInst = corner;
            }
            //列头
            BuildHeader(rptData, ColHeader, matrixInst);
            //行头
            BuildHeader(rptData, RowHeader, matrixInst);
            //数据
            foreach (RptMtxHeaderInst rowHeaderInst in matrixInst.RowHeaderInsts)
            {
                foreach (RptMtxHeaderInst colHeaderInst in matrixInst.ColHeaderInsts)
                {
                    RptText cell = GetCellByRowCol(rowHeaderInst.MtxRowsRow, colHeaderInst.MtxRowsCol);
                    if (cell != null)
                    {
                        RptTextInst txtInst = new RptTextInst(cell);
                        Dictionary <string, string> filter = new Dictionary <string, string>();
                        foreach (string key in rowHeaderInst.Filter.Keys)
                        {
                            filter.Add(key, rowHeaderInst.Filter[key]);
                        }
                        foreach (string key in colHeaderInst.Filter.Keys)
                        {
                            filter.Add(key, colHeaderInst.Filter[key]);
                        }
                        txtInst.Filter = filter;
                        matrixInst.AddCell(txtInst);
                    }
                }
            }
        }
Beispiel #13
0
 void InsertCells(RptTblPart p_part, int p_index, Dictionary <string, RptText> p_dict, string p_pre)
 {
     if (p_part != null)
     {
         for (int i = 0; i < p_part.Rows.Count; i++)
         {
             RptText text = p_dict[p_pre + i.ToString()];
             p_part.Rows[i].Cells.Insert(p_index, text);
         }
     }
 }
Beispiel #14
0
        public RptMtxSubtotal(RptItemBase p_parent)
        {
            _parent   = p_parent;
            Item      = new RptText(this);
            SubTotals = new List <RptMtxSubtotal>();

            // 是否在层次前面
            _data.AddCell("beforelevel", "1");
            // 所占行数/列数
            _data.AddCell("span", 1);
        }
Beispiel #15
0
        internal void LoadItem(RptText p_item)
        {
            _title = p_item.Parent as RptMtxSubtitle;

            Row row = new Row();

            row.AddCell("span", _title.Data.Int("span"));
            row.Changed += OnChanged;
            _fv.Data     = row;

            _fvMtx.LoadItem(_title.Level.Matrix);
        }
Beispiel #16
0
 void RemoveCells(RptTblPart p_part, int p_index, Dictionary <string, RptText> p_dict, string p_pre)
 {
     if (p_part != null)
     {
         for (int i = 0; i < p_part.Rows.Count; i++)
         {
             RptText text = p_part.Rows[i].Cells[p_index];
             p_dict.Add(p_pre + i.ToString(), text);
             p_part.Rows[i].Cells.RemoveAt(p_index);
         }
     }
 }
Beispiel #17
0
        /// <summary>
        /// 构建table的单元格。
        /// </summary>
        /// <param name="p_tblRow"></param>
        /// <param name="p_colSpan"></param>
        internal static void BuildCells(RptTblPartRow p_tblRow, int p_colSpan)
        {
            RptText txt;

            for (int i = 0; i < p_colSpan; i++)
            {
                txt         = new RptText(p_tblRow);
                txt.RowSpan = 1;
                txt.ColSpan = 1;
                p_tblRow.Cells.Add(txt);
            }
        }
Beispiel #18
0
        /// <summary>
        /// 克隆行
        /// </summary>
        /// <param name="p_mat"></param>
        /// <returns></returns>
        public RptMtxRow Clone(RptMatrix p_mat)
        {
            RptMtxRow row = new RptMtxRow(p_mat);

            foreach (RptText txt in Cells)
            {
                RptText newtxt = new RptText(row);
                newtxt.Data.Copy(txt.Data);
                row.Cells.Add(newtxt);
            }
            return(row);
        }
Beispiel #19
0
        internal void LoadItem(RptText p_item)
        {
            _total = p_item.Parent as RptMtxSubtotal;

            Row row = new Row();

            row.AddCell("span", _total.Data.Int("span"));
            row.AddCell("beforelevel", _total.Data.Bool("beforelevel"));
            row.Changed += OnChanged;
            _fv.Data     = row;

            _fvMtx.LoadItem(_total.Level.Matrix);
        }
Beispiel #20
0
 internal async Task <bool> Show(FrameworkElement p_target, RptText p_item)
 {
     _lv.Data = p_item.Root.Params.Data;
     if (!Kit.IsPhoneUI)
     {
         WinPlacement    = DlgPlacement.TargetOuterLeftTop;
         PlacementTarget = p_target;
         ClipElement     = p_target;
         Height          = 400;
         Width           = 300;
     }
     return(await ShowAsync());
 }
Beispiel #21
0
        /// <summary>
        /// 恢复单元格原始值,撤消
        /// </summary>
        /// <param name="p_args"></param>
        public override void Undo(object p_args)
        {
            IsSetting = true;
            ValueChangedArgs args = (ValueChangedArgs)p_args;

            args.Cell.Val = args.OldVal;
            RptText text = args.RptText;

            if (text != null)
            {
                text.Update(false);
            }
            IsSetting = false;
        }
Beispiel #22
0
        /// <summary>
        /// 加载xml
        /// </summary>
        /// <param name="p_reader"></param>
        public virtual void ReadXml(XmlReader p_reader)
        {
            p_reader.MoveToElement();
            if (p_reader.IsEmptyElement)
            {
                p_reader.Read();
                return;
            }

            string name = p_reader.Name;

            p_reader.Read();
            while (p_reader.NodeType != XmlNodeType.None)
            {
                if (p_reader.NodeType == XmlNodeType.EndElement && p_reader.Name == name)
                {
                    break;
                }

                RptItem item = null;
                switch (p_reader.Name)
                {
                case "Text":
                    item = new RptText(this);
                    break;

                case "Table":
                    item = new RptTable(this);
                    break;

                case "Matrix":
                    item = new RptMatrix(this);
                    break;

                case "Chart":
                    item = new RptChart(this);
                    break;

                default:
                    if (item == null)
                    {
                        Kit.Error(string.Format("反序列化报表模板时错误,无法识别报表项【{0}】!", p_reader.Name));
                    }
                    break;
                }
                item.ReadXml(p_reader);
                Items.Add(item);
            }
            p_reader.Read();
        }
Beispiel #23
0
        /// <summary>
        /// 添加新行
        /// </summary>
        /// <param name="p_matrix">矩阵</param>
        /// <param name="p_index">插入位置</param>
        /// <returns>新增行</returns>
        RptMtxRow InsertNewRow(RptMatrix p_matrix, int p_index)
        {
            RptMtxRow row      = new RptMtxRow(p_matrix);
            int       rowCount = p_matrix.GetCellsCount();

            for (int i = 0; i < p_matrix.Rows[0].Cells.Count; i++)
            {
                RptText text = new RptText(row);
                text.Val = string.Format("cell{0}", (rowCount + i).ToString());
                row.Cells.Add(text);
            }
            p_matrix.Rows.Insert(p_index, row);
            return(row);
        }
Beispiel #24
0
        RptTblPartRow CopyTableRow(RptTblPartRow p_source, RptTblPartRow p_dest)
        {
            RptText text   = null;
            RptText newTxt = null;

            for (int i = 0; i < p_source.Cells.Count; i++)
            {
                text   = p_source.Cells[i];
                newTxt = (RptText)text.Clone();
                newTxt.SetParentItem(p_dest);
                p_dest.Cells.Add(newTxt);
            }

            return(p_dest);
        }
Beispiel #25
0
 void BuildCells(RptTblPart p_part, int p_index)
 {
     if (p_part != null)
     {
         foreach (RptTblPartRow r in p_part.Rows)
         {
             RptText txt = new RptText(r);
             txt.Row     = r.Row;
             txt.RowSpan = 1;
             txt.Col     = p_index;
             txt.ColSpan = 1;
             r.Cells.Insert(p_index, txt);
         }
     }
 }
Beispiel #26
0
        /// <summary>
        /// 设置单元格新值,重做
        /// </summary>
        /// <param name="p_args"></param>
        /// <returns></returns>
        public override object Execute(object p_args)
        {
            IsSetting = true;
            ValueChangedArgs args = (ValueChangedArgs)p_args;

            args.Cell.Val = args.Val;
            RptText text = args.RptText;

            if (text != null)
            {
                text.Update(false);
            }
            IsSetting = false;
            return(null);
        }
Beispiel #27
0
        /// <summary>
        /// 加载table的行单元格,不进行样式清除工作
        /// </summary>
        /// <param name="p_tblRow"></param>
        /// <param name="p_rowIdx"></param>
        /// <param name="p_colIdx"></param>
        void LoadTblRow(RptTblPartRow p_tblRow, int p_rowIdx, int p_colIdx)
        {
            int       colIdx = p_colIdx;
            Worksheet ws     = _owner.Excel.Sheets[0];

            for (int i = 0; i < p_tblRow.Cells.Count; i++)
            {
                RptText txt = p_tblRow.Cells[i];
                txt.Row = p_rowIdx;
                txt.Col = colIdx++;

                Dt.Cells.Data.Cell cell = ws[txt.Row, txt.Col];
                cell.Value = txt.Data.Str("val");
                txt.ApplyStyle(cell);
            }
        }
Beispiel #28
0
 void LoadCellForm(RptText p_txt)
 {
     if (p_txt == null)
     {
         _tabCell.Content = null;
     }
     else
     {
         if (_fmText == null)
         {
             _fmText = new TextForm();
         }
         _fmText.LoadItem(p_txt);
         _tabCell.Content = _fmText;
     }
 }
Beispiel #29
0
        public override object Execute(object p_args)
        {
            InsertCmdArgs args  = (InsertCmdArgs)p_args;
            RptText       txt   = args.RptItem as RptText;
            CellRange     range = args.CellRange;

            txt.Row         = range.Row;
            txt.Col         = range.Column;
            txt.RowSpan     = range.RowCount;
            txt.ColSpan     = range.ColumnCount;
            txt.Val         = "文本";
            txt.LeftStyle   = BorderLineStyle.None;
            txt.TopStyle    = BorderLineStyle.None;
            txt.RightStyle  = BorderLineStyle.None;
            txt.BottomStyle = BorderLineStyle.None;
            txt.Part.Items.Add(txt);
            return(txt);
        }
Beispiel #30
0
        /// <summary>
        /// 输出报表项内容
        /// </summary>
        protected override void DoOutput()
        {
            RptText     item = _item as RptText;
            RptRootInst root = Inst;

            root.OutputItem(this);
            ParseValue();
            if (!item.AutoHeight || _region.RowSpan > 1)
            {
                return;
            }

            // 处理自动行高
            double height = 0;

            Kit.RunSync(() =>
            {
                // 测量文本的实际高度
                TextBlock tb    = new TextBlock();
                tb.TextWrapping = item.WordWrap ? TextWrapping.Wrap : TextWrapping.NoWrap;
                tb.FontFamily   = new FontFamily(item.FontFamily);
                tb.FontSize     = item.FontSize;
                if (item.Bold)
                {
                    tb.FontWeight = FontWeights.Bold;
                }
                if (item.Italic)
                {
                    tb.FontStyle = FontStyle.Italic;
                }
                tb.Text  = Text;
                tb.Width = Width - 8 - item.Margin * 2;
                tb.Measure(new Size(double.MaxValue, double.MaxValue));
                height = Math.Ceiling(tb.ActualHeight) + 4;
            });
            root.SyncRowHeight(this, height);
        }