コード例 #1
0
        private async void OpeningbalancesPageNav()
        {
            if (Suppliers.Count() != 0)
            {
                await Navigation.PushAsync(new SuppliersOpeningbalances(Suppliers));
            }
            else
            {
                await GetData();

                await Navigation.PushAsync(new SuppliersOpeningbalances(Suppliers));
            }
        }
コード例 #2
0
        private async void ClientRecievableNav()
        {
            if (Suppliers.Count() != 0)
            {
                await Navigation.PushAsync(new SupplierRecivable(Suppliers));
            }
            else
            {
                await GetData();

                await Navigation.PushAsync(new SupplierRecivable(Suppliers));
            }
        }
コード例 #3
0
        public async Task <IActionResult> OnPostExport(int currentPage, int pageSize, string searchString, string sortOrder)
        {
            Suppliers = await InitiateView(currentPage, pageSize, searchString, sortOrder);

            string   sWebRootFolder = _hostingEnvironment.WebRootPath;
            string   sFileName      = @"Suppliers Data.xlsx";
            string   URL            = string.Format("{0}://{1}/{2}", Request.Scheme, Request.Host, sFileName);
            FileInfo file           = new FileInfo(Path.Combine(sWebRootFolder, sFileName));
            var      memory         = new MemoryStream();

            using (var fs = new FileStream(Path.Combine(sWebRootFolder, sFileName), FileMode.Create, FileAccess.Write))
            {
                ExcelPackage package = new ExcelPackage();
                package.Workbook.Worksheets.Add("Suppliers");
                ExcelWorksheet categoriesSheet = package.Workbook.Worksheets["Suppliers"];
                using (var range = categoriesSheet.Cells["A1:F1"])
                {
                    range.Style.Font.Bold        = true;
                    range.Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;
                    range.Style.Fill.BackgroundColor.SetColor(Color.FromArgb(23, 121, 186));
                    range.Style.Font.Color.SetColor(Color.White);
                }
                categoriesSheet.Cells[1, 1].Value = "Id";
                categoriesSheet.Cells[1, 2].Value = "Name";
                categoriesSheet.Cells[1, 3].Value = "Email";
                categoriesSheet.Cells[1, 4].Value = "Phone";
                categoriesSheet.Cells[1, 5].Value = "Address";
                categoriesSheet.Cells[1, 6].Value = "Contact";
                for (int r = 0; r < Suppliers.Count(); r++)
                {
                    categoriesSheet.Cells[r + 2, 1].Value = Suppliers.ToList()[r].Id;
                    categoriesSheet.Cells[r + 2, 2].Value = Suppliers.ToList()[r].Name;
                    categoriesSheet.Cells[r + 2, 3].Value = Suppliers.ToList()[r].Email;
                    categoriesSheet.Cells[r + 2, 4].Value = Suppliers.ToList()[r].Phone;
                    categoriesSheet.Cells[r + 2, 5].Value = Suppliers.ToList()[r].Address;
                    categoriesSheet.Cells[r + 2, 6].Value = Suppliers.ToList()[r].Contact;
                    categoriesSheet.Cells[1, 1, 1, 6].AutoFitColumns();
                }

                package.SaveAs(fs);
                package.Dispose();
            }
            using (var stream = new FileStream(Path.Combine(sWebRootFolder, sFileName), FileMode.Open))
            {
                await stream.CopyToAsync(memory);
            }
            memory.Position           = 0;
            TempData["StatusMessage"] = "Supplier list successfully exported to file " + sFileName + ".";
            return(File(memory, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", sFileName));
        }