示例#1
0
        public async Task <ActionResult> DownloadPowerpointTableDocument()
        {
            TableGeneratorPowerPoint powerpoint = new TableGeneratorPowerPoint();

            // we need to use anonoymus type to set the custom label names
            var customers = await _context.Customers.Select(x => new
            {
                FullName = x.ContactName,
                Company  = x.CompanyName,
                JobTitle = x.ContactTitle,
                x.Address,
                x.City,
            }).ToListAsync();

            var title = "Customers";

            var fileName = Helpers.GetPowerpointDocumentFileName(title);

            powerpoint.Run(customers, title, fileName);

            //download file
            byte[] fileBytes = await Helpers.DownloadFile(fileName, _configuration, _hostingEnvironment);

            var file = File(fileBytes, "application/x-msdownload", fileName);

            return(file);
        }
示例#2
0
        public void CreateTable()
        {
            ContextDbService service = new ContextDbService();
            var context = service.GetDbContext();

            var tableGenerator = new TableGeneratorPowerPoint();

            var customers = context.Customers.Select(c => new { c.ContactName, c.CompanyName, c.ContactTitle, c.Address, c.City, c.Country });

            var fileName = $"Customers {DateTime.Now.ToString().Replace("/", "_").Replace(":", "_")}.ppt";

            tableGenerator.Run(customers, "Customers", fileName);
        }