コード例 #1
0
        public ActionResult TableServerSideGetData(int pageIndex, int pageSize, string filter = "")
        {
            var db       = new Config_AllowanceDAL();
            int total    = 0;
            var result   = db.Config_Allowance_GetList(pageIndex, pageSize, filter, out total);
            var lstTotal = new TableColumnsTotalModel();

            lstTotal.Total1 = "15";
            lstTotal.Total2 = "25";
            lstTotal.Total3 = "35";
            return(Content(JsonConvert.SerializeObject(new
            {
                employees = result,
                totalCount = total,
                lstTotal = lstTotal
            })));
        }
コード例 #2
0
        public ActionResult ConfigAllowanceExportExcel(string filter)
        {
            DataTable dt = new DataTable("Grid");

            dt.Columns.AddRange(new DataColumn[]
            {
                new DataColumn(AppRes.Allowance),
                new DataColumn(AppRes.AllowanceEN),
                new DataColumn(AppRes.FromAmount),
                new DataColumn(AppRes.ToAmount),
                new DataColumn(AppRes.Formular),
                new DataColumn(AppRes.Note),
            });
            dt.Columns[0].DataType = typeof(string);
            dt.Columns[1].DataType = typeof(string);
            dt.Columns[2].DataType = typeof(double);
            dt.Columns[3].DataType = typeof(double);
            dt.Columns[4].DataType = typeof(string);
            dt.Columns[5].DataType = typeof(string);

            var db           = new Config_AllowanceDAL();
            int total        = 0;
            int LanguageCode = Global.CurrentUser.CurrentLanguageID;
            var lstData      = db.Config_Allowance_GetList(1, 5000, filter, out total);

            foreach (var item in lstData)
            {
                dt.Rows.Add(item.Name, item.NameEN, item.FromAmount, item.ToAmount, item.sFormular, item.Note);
            }

            var wb = new XLWorkbook();

            wb.Worksheets.Add(dt);
            byte[] data = null;
            using (var stream = new MemoryStream())
            {
                wb.SaveAs(stream);
                data = stream.ToArray();
            }
            return(File(data, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "Config_Allowance.xlsx"));
        }