Example #1
0
        public void ExportTest()
        {
            List <ExportCar> list = new List <ExportCar>();

            for (int i = 0; i < 5; i++)
            {
                list.Add(new ExportCar()
                {
                    Name         = "龚英韬",
                    Age          = 22,
                    CarCode      = "SSSS",
                    Gender       = GenderEnum.男,
                    RegisterDate = DateTime.Now
                });
            }

            for (int i = 0; i < 600; i++)
            {
                list.Add(new ExportCar()
                {
                    Name         = "龚英韬111",
                    Age          = 22,
                    CarCode      = "对对对对对对多多多多多多多多多多多多多多多多多多多多多多多多多多多多多多多多多多多多",
                    Gender       = GenderEnum.男,
                    RegisterDate = DateTime.Now
                });
            }

            IWorkbook wk = ExcelExportService.Export <ExportCar>(list);

            Assert.True(wk != null);


            File.WriteAllBytes(@"c:\test\test.xls", wk.ToBytes());
        }
Example #2
0
        public dynamic ExportToExcelAsync()
        {
            Stream stream = _excelExportService.Export(
                _usageRecordsRepository.UsageRecords.AsNoTracking());

            return(this.File(stream, "text/plain", "EquipmentUsageRecord.xlsx"));
        }
        public IActionResult Get()
        {
            Stream stream = _excelExportService.Export(
                _repository.UsageRecords.OrderBy(item => item.StartTime)
                .Include(item => item.Project).Include(item => item.EquipmentHourlyRate));

            return(File(stream, "text/plain", "EquipmentUsageRecord.xlsx"));
        }
        //
        // GET: /Admin/
        public ActionResult Index()
        {
            var result = ExportService.Export(Request.QueryString);

            ExcelExportService service = new ExcelExportService();

            service.Export(result, Response);

            return(View());
        }
        public ActionResult ExportExcel()
        {
            IEnumerable <dynamic> bankData = null;

            if (TempData["xlsTemp"] != null)
            {
                bankData = TempData["xlsTemp"] as IEnumerable <客戶銀行資訊>;
                bankData = bankData.Select(x =>
                                           new { Id = x.Id, 銀行名稱 = x.銀行名稱, 分行代碼 = x.分行代碼, 銀行代碼 = x.銀行代碼, 帳戶名稱 = x.帳戶名稱, 帳戶號碼 = x.帳戶號碼 });
            }
            else
            {
                bankData = _BankRepository.All().Select(x =>
                                                        new { Id = x.Id, 銀行名稱 = x.銀行名稱, 分行代碼 = x.分行代碼, 銀行代碼 = x.銀行代碼, 帳戶名稱 = x.帳戶名稱, 帳戶號碼 = x.帳戶號碼 }).AsEnumerable <dynamic>();
            }
            var header = new List <string>()
            {
                "Id", "銀行名稱", "分行代碼", "銀行代碼", "帳戶名稱", "帳戶號碼"
            };
            var fileName = ExcelExportService.Export(Server.MapPath("~/App_Data"), "客戶銀行資訊", header, bankData);

            return(File(fileName, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "ExportFile.xlsx"));
        }
Example #6
0
        public ActionResult ExportExcel()
        {
            IEnumerable <dynamic> contactData = null;

            if (TempData["xlsTemp"] != null)
            {
                contactData = TempData["xlsTemp"] as IEnumerable <客戶聯絡人>;
                contactData = contactData.Select(x =>
                                                 new { Id = x.Id, 姓名 = x.姓名, 職稱 = x.職稱, 手機 = x.手機, 電話 = x.電話 });
            }
            else
            {
                contactData = _ContactRepository.All().Select(x =>
                                                              new { Id = x.Id, 姓名 = x.姓名, 職稱 = x.職稱, 手機 = x.手機, 電話 = x.電話 }).AsEnumerable <dynamic>();
            }
            var header = new List <string>()
            {
                "Id", "姓名", "職稱", "手機", "電話"
            };
            var fileName = ExcelExportService.Export(Server.MapPath("~/App_Data"), "客戶聯絡人", header, contactData);

            return(File(fileName, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "ExportFile.xlsx"));
        }