public static Sheet VoucherStatementTemplate(VoucherStatementPageResult result)
        {
            ExcelReportBuilder builder = new();
            Sheet sheet = new("RemainReport");

            sheet.IsLocked = false;
            var row = builder.AddRow(new List <string> {
                "کد حساب", "بدهکار", "بستانکار"
            }, new RowPropertyOptions(new Location("A", 3)));
            var cell = builder.AddCell(result.ReportName, "ReportName",
                                       new CellsPropertyOptions(new Location("H", 1)));
            var table           = builder.AddTable(result.RowResult, new TablePropertyOptions(new Location("A", 4)));
            var currentLocation = table.NextVerticalLocation;
            var row2            = builder.AddRow(new List <string> {
                "کد حساب", "بدهکار", "بستانکار"
            }, new RowPropertyOptions(currentLocation));

            currentLocation = row2.NextVerticalLocation;
            var table2 = builder.AddTable(result.RowResult, new TablePropertyOptions(currentLocation));

            currentLocation = table2.NextVerticalLocation;
            var accountheader = TableTemplates.AccountHeader(currentLocation);

            currentLocation = accountheader.NextVerticalLocation;
            var accounts = TableTemplates.Accounts(result.Accounts, currentLocation);

            currentLocation = accounts.NextHorizontalLocation;
            currentLocation = new Location(currentLocation.X, currentLocation.Y - 3);

            var multiplexHeader = TableTemplates.Multiplex(result.SummaryAccounts, currentLocation);


            Border border = new(LineStyle.Thick, Color.Black);

            row.BackColor        = Color.Gray;
            row2.BackColor       = Color.Gray;
            table.InlineBorder   = border;
            table.OutsideBorder  = border;
            table2.InlineBorder  = border;
            table2.OutsideBorder = border;
            sheet.Tables.Add(table);
            sheet.Tables.Add(table2);
            sheet.Tables.Add(accountheader);
            sheet.Tables.Add(accounts);
            sheet.Tables.Add(multiplexHeader);
            sheet.Rows.Add(row);
            sheet.Rows.Add(row2);
            sheet.Cells.Add(cell);
            ColumnProps column = new ColumnProps();

            column.IsLocked = true;
            column.ColumnNo = 1;
            sheet.Columns   = new List <ColumnProps> {
                column
            };
            sheet.MergedCells.Add("A1:H2");
            sheet.MergedCells.Add("L17:L18");
            return(sheet);
        }
        public static ExcelGeneratedFileResult VoucherStatementExcelReport(VoucherStatementPageResult result)
        {
            var workBook = new WorkBook {
                FileName = "FileName"
            };
            var sheet1 = SheetTemplates.VoucherStatementTemplate(result);

            workBook.Sheets.Add(sheet1);

            // Generate Excel from "WorkBook" instance
            return(ExcelService.GenerateExcel(workBook));
        }
        public static string VoucherStatementExcelReportUrl(VoucherStatementPageResult result, string basePath, string excelName)
        {
            var workBook = new WorkBook {
                FileName = "FileName"
            };
            var sheet1 = SheetTemplates.VoucherStatementTemplate(result);

            workBook.Sheets.Add(sheet1);

            // Generate Excel from "WorkBook" instance
            return(ExcelService.GenerateExcel(workBook, basePath, excelName));
        }
Пример #4
0
        public IActionResult ExportExcel()
        {
            var arg = new VoucherStatementPageResult
            {
                ReportName      = "TestReport",
                SummaryAccounts = new List <SummaryAccount>
                {
                    new SummaryAccount
                    {
                        AccountName = "کارخانه دان-51011",
                        Multiplex   = new List <Multiplex>
                        {
                            new Multiplex {
                                After = 5000000, Befor = 4000
                            },
                        },
                    },
                    new SummaryAccount
                    {
                        AccountName = "پرورش پولت-51018",
                        Multiplex   = new List <Multiplex>
                        {
                            new Multiplex {
                                After = 5000000, Befor = 4000
                            },
                        },
                    },
                    new SummaryAccount
                    {
                        AccountName = "تخم گزار تجاری-51035",
                        Multiplex   = new List <Multiplex>
                        {
                            new Multiplex {
                                After = 5000000, Befor = 4000
                            },
                        },
                    }
                },

                Accounts = new List <AccountDto>
                {
                    new AccountDto
                    {
                        Name = "حقوق پایه",
                        Code = "81010"
                    },
                    new AccountDto
                    {
                        Name = "اضافه کار",
                        Code = "81011"
                    },
                },
                RowResult = new List <VoucherStatementRowResult>
                {
                    new VoucherStatementRowResult
                    {
                        AccountCode = "13351",
                        Credit      = 50000,
                        Debit       = 0
                    },
                    new VoucherStatementRowResult
                    {
                        AccountCode = "21253",
                        Credit      = 0,
                        Debit       = 50000
                    },
                    new VoucherStatementRowResult
                    {
                        AccountCode = "13556",
                        Credit      = 1000000,
                        Debit       = 0
                    },
                    new VoucherStatementRowResult
                    {
                        AccountCode = "13500",
                        Credit      = 1000000,
                        Debit       = 0
                    },
                    new VoucherStatementRowResult
                    {
                        AccountCode = "13499",
                        Credit      = 2000000,
                        Debit       = 0
                    },
                    new VoucherStatementRowResult
                    {
                        AccountCode = "22500",
                        Credit      = 0,
                        Debit       = 4000000
                    }
                }
            };



            var result2     = ExcelReportGenerator.VoucherStatementExcelReport(arg);
            var result22Url = ExcelReportGenerator.VoucherStatementExcelReportUrl(arg, @"E:\TestFolder", "MyCustomName");


            var result = ExcelReportGenerator.TestReport();

            return(Ok(result22Url));
        }