Example #1
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();
        }
Example #2
0
        void OnInsertText(object sender, Mi e)
        {
            Worksheet sheet = _owner.Excel.ActiveSheet;
            CellRange range = sheet.Selections[0];

            Dt.Cells.Data.Cell cell = sheet[range.Row, range.Column];
            //合并单元格
            if (range.RowCount > 1 || range.ColumnCount > 1)
            {
                cell.RowSpan    = range.RowCount;
                cell.ColumnSpan = range.ColumnCount;
            }
            _owner.Info.ExecuteCmd(RptCmds.InsertText, new InsertCmdArgs(new RptText(_owner.GetContainer()), range));
        }
Example #3
0
        /// <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);
            }
        }