Ejemplo n.º 1
0
        /// <summary>
        /// 删除小计行,并将同一Sheet中的多个工程量表进行合并
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_MergeSumRow_Click(object sender, RibbonControlEventArgs e)
        {
            Application app = Globals.ThisAddIn.Application;
            var         sht = app.ActiveSheet as Worksheet;
            //

            var rg = app.InputBox("选择要进行小计行删除的第一页数据,包括小计行。", Type: 8) as Range;

            if (rg != null)
            {
                var sumRows = ExcelFunction.GetMultipleRowNum(app, "选择第一页中的多个小计行:");
                if (sumRows.Count == 0)
                {
                    return;
                }
                //
                int?lastRow = ExcelFunction.GetRowNum(app, "选择要处理的最后一行数据:");
                if (lastRow == null)
                {
                    return;
                }
                //
                SumRowHandler.DeleteSumupRow(app, page1: rg, sumRows: sumRows, lastRow: lastRow.Value);
            }
            app.ScreenUpdating = true;
        }
Ejemplo n.º 2
0
        // 开始具体的调试操作
        private static void DoSomething(Application app)
        {
            Worksheet sht  = app.ActiveSheet;
            Workbook  wkbk = app.ActiveWorkbook;


            var rg = app.InputBox("选择要进行小计行删除的第一页数据,包括小计行。", Type: 8) as Range;

            if (rg != null)
            {
                var sumRows = ExcelFunction.GetMultipleRowNum(app, "选择第一页中的多个小计行:");
                if (sumRows.Count == 0)
                {
                    return;
                }
                //
                int?lastRow = ExcelFunction.GetRowNum(app, "选择要处理的最后一行数据的行号:");
                if (lastRow == null)
                {
                    return;
                }
                //
                SumRowHandler.DeleteSumupRow(app, page1: rg, sumRows: sumRows, lastRow: lastRow.Value);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 对于有很多行数据的工程量表,自动将多数据行进行分隔,并插入小计行
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_SumupInsertRow_Click(object sender, RibbonControlEventArgs e)
        {
            Application app = Globals.ThisAddIn.Application;
            var         sht = app.ActiveSheet as Worksheet;
            //
            var rg = app.InputBox("选择第二页表格中的区域(包括第一页表格中的小计行,以及第二页表格中最后一行)", Type: 8) as Range;

            if (rg != null)
            {
                int?lastRow = ExcelFunction.GetRowNum(app, "最后一行数据:");

                if (lastRow != null)
                {
                    var   sumupRow    = rg.Rows[1] as Range;
                    Range indexColumn = sht.Range[rg.Cells[2, 1], rg.Cells[rg.Rows.Count - 1, 1]] as Range;

                    var startRow      = sumupRow.Row + 1;
                    var dataRowsCount = indexColumn.Count;
                    //
                    SumRowHandler.InsertSumupRow(app, sumupRow: sumupRow, indexColumn: indexColumn,
                                                 startRow: startRow, dataRowsCount: dataRowsCount, lastRow: lastRow.Value);
                }
                else
                {
                    MessageBox.Show(@"请输入一个数值");
                }
            }
            app.ScreenUpdating = true;
        }
Ejemplo n.º 4
0
        // 开始具体的调试操作
        private static void DoSomething(Application app)
        {
            Worksheet sht  = app.ActiveSheet;
            Workbook  wkbk = app.ActiveWorkbook;


            var rg = app.InputBox("选择第二张表格中的区域(包括第一个表格中的小计行)", Type: 8) as Range;

            if (rg != null)
            {
                int?lastRow = 0;
                lastRow = ExcelFunction.GetRowNum(app, "最后一行数据的行号:");
                if (lastRow != null)
                {
                    var   sumupRow    = rg.Rows[1] as Range;
                    Range indexColumn = sht.Range[rg.Cells[2, 1], rg.Cells[rg.Rows.Count - 1, 1]] as Range;

                    var startRow      = sumupRow.Row + 1;
                    var dataRowsCount = indexColumn.Count;
                    //
                    SumRowHandler.InsertSumupRow(app, sumupRow: sumupRow, indexColumn: indexColumn,
                                                 startRow: startRow, dataRowsCount: dataRowsCount, lastRow: lastRow.Value);
                }
                else
                {
                    MessageBox.Show(@"请输入一个数值");
                }
            }
            return;

            //
            SumRowHandler.InsertSumupRow(app, sht.Range["A36:Q36"], sht.Range["A37:A64"], 37, 28, 1010 + 7);
            return;

            var slpHdl = new SlopeInfoHandler(app);

            slpHdl.Execute(containsHeader: true);
        }