private void btnConfirm_Click(object sender, EventArgs e)
        {
            string companyCode = txtCompany.Text.ToUpper().Trim();
            string year        = txtYear.Text.Trim();
            string month       = txtMonth.Text.Trim();

            if (this.Tag.ToString().Equals("BS"))
            {
                GenerateBalanceSheet(companyCode, year, month);
            }

            if (this.Tag.ToString().Equals("TB"))
            {
                var       bsService = new BalanceSheetService(companyCode, year, month);
                DataTable bsItems   = bsService.GetBsItemsDetail();

                // Copy Template
                string fullPath = ExcelUtils.TemplatePath + "B000_Trial_Balance_v1.xltx";
                ExcelUtils.CopyTemplate(fullPath, "TB", ThisAddIn.ExcelApp.ActiveSheet);

                ExcelUtils.CopyFromDataTable(bsItems, ThisAddIn.ExcelApp.ActiveSheet, false);

                // 在RuntimeReports中记录当前的报表和worksheet对应
                RuntimeReports.Add(new RuntimeReport()
                {
                    ReportInstance = bsService,
                    WorksheetName  = ThisAddIn.ExcelApp.ActiveSheet.Name
                });
            }

            this.Close();
        }
Esempio n. 2
0
        public void drillDownButton_Click(Office.IRibbonControl ctrl)
        {
            string sheetName      = Globals.ThisAddIn.Application.ActiveSheet.Name;
            object reportInstance = RuntimeReports.FindReportByWorksheet(sheetName);

            if (reportInstance == null)
            {
                return;
            }
            if (!(reportInstance is BalanceSheetService))
            {
                return;
            }

            string cellAddr = ExcelUtils.GetRelativeAddress(ThisAddIn.ExcelApp.ActiveCell);
            BalanceSheetService bsService = (BalanceSheetService)reportInstance;

            string fsItem = bsService.FindFsItem(cellAddr); // 根据单元格地址查找报表项

            if (fsItem != null)
            {
                System.Data.DataTable tbItems = bsService.GetBsItemsDetail();
                System.Data.DataView  tbView  = new System.Data.DataView(tbItems);
                tbView.RowFilter = $"FSItem = '{fsItem}' ";
                System.Data.DataTable rv = tbView.ToTable();

                // Copy Template
                string fullPath = ExcelUtils.TemplatePath + "B000_Trial_Balance_v1.xltx";
                ExcelUtils.CopyTemplate(fullPath, "TB", ThisAddIn.ExcelApp.ActiveSheet);

                ExcelUtils.CopyFromDataTable(rv, ThisAddIn.ExcelApp.ActiveSheet, false);
            }
        }
Esempio n. 3
0
        private void btnConfirm_Click(object sender, EventArgs e)
        {
            var sapService = new SAPTableServiceNCo();

            if (tableFieldsCheckBox.Checked)
            {
                var       tableFields = sapService.GetTableFields(txtTableName.Text.Trim().ToUpper());
                Worksheet sheet       = ThisAddIn.ExcelApp.Worksheets.Add();
                sheet.Name = $"{txtTableName.Text.ToUpper()}_strucutre_{sheet.Name}";
                ExcelUtils.CopyFromDataTable(tableFields, sheet);
            }

            if (tableContentCheckBox.Checked)
            {
                var tableContent = sapService.GetTableContent(txtTableName.Text.ToUpper().Trim(),
                                                              Convert.ToInt32(txtRows.Text),
                                                              txtCriteria.Text);
                Worksheet sheet = ThisAddIn.ExcelApp.Worksheets.Add();
                sheet.Name = $"{txtTableName.Text.ToUpper()}_{sheet.Name}";
                ExcelUtils.CopyFromDataTable(tableContent, sheet);
            }

            this.Close();
        }