예제 #1
0
        public ActionResult Download(AksesGroupViewModel model)
        {
            try
            {
                XLWorkbook xlWorkBook  = new XLWorkbook();
                var        xlWorkSheet = xlWorkBook.Worksheets.Add("Master AksesGroup");// xlWorkSheet;

                xlWorkSheet.Cell(1, 1).Value = "GroupId";
                xlWorkSheet.Cell(1, 2).Value = "Deskripsi";

                IAksesGroupService svc = new AksesGroupService();
                var Data = svc.GetAll();
                int Row  = 2;
                if (Data.Count > 0)
                {
                    for (int i = 0; i < Data.Count; i++)
                    {
                        xlWorkSheet.Cell(Row + i, 1).Value = Data[i].GroupID;
                        xlWorkSheet.Cell(Row + i, 2).Value = Data[i].Description;
                    }
                    xlWorkSheet.Columns().AdjustToContents();
                    var path = Server.MapPath("..") + "\\Master-AksesGroup.xlsx";
                    xlWorkBook.SaveAs(path);
                    xlWorkBook.Dispose();
                    return(File(path, "application/vnd.ms-excel", "Master-AksesGroup.xlsx"));
                }

                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                general.AddLogError("Akses Group", ex.Message, ex.StackTrace);
                return(View("~/Views/Master/AksesGroup/Index.cshtml"));
            }
        }
예제 #2
0
        public ActionResult Index()
        {
            IAksesGroupService svc = new AksesGroupService();
            var model = svc.GetAll();

            return(View("~/Views/Master/AksesGroup/Index.cshtml", model));
        }