Skip to content

excel report #5515

Answered by luongnv6
samaremad asked this question in Help
Feb 21, 2021 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

Here is code for you

 public FileContentResult ListExcel(IDbConnection connection, ListRequest request)
        {
            var data = List(connection, request).Entities;
            var includeColumns = request.IncludeColumns.Where(p => p != "ImageColumnName");
            var report = new DynamicDataReport(data, includeColumns, typeof(Columns.OutsideSalesReportColumns));
            using (var excelPackage = new ReportRepository().RenderExcelPackage(report))
            {
                return ExcelContentResult.Create(excelPackage.GetAsByteArray(), $"ExcelNameFile_{DateTime.Now:yyyyMMdd_HHmmss}.xlsx");
            }
        }

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@samaremad
Comment options

Answer selected by samaremad
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants