Ejemplo n.º 1
0
        /// <summary>
        /// 保存文件
        /// </summary>
        /// <param name="dtHe"></param>
        private static void saveFile(DataTable dtHe)
        {
            string dir      = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
            string saveFile = dir + "\\合并考勤表.xls";

            NpoiHelper.Export(dtHe, "合并考勤表", saveFile);
            MessageBox.Show("生成成功!文件已经保存在" + saveFile, "消息提示");
            Console.Out.WriteLine("生成成功");
        }
Ejemplo n.º 2
0
        public JsonResult Export()
        {
            try
            {
                //导出所有数据
                var All_ListData = UserEntites.UserInfo.ToList();

                //将list 转化为datatable类型
                var Dt = DatabaseOpreas._.ListToDataTable(All_ListData);

                NpoiHelper.Export(Dt, "用户信息", Server.MapPath("~/Content/Export.xls"));//这里的路径是需要写入你需要保存的文件格式的,不需要创建自动检测创建

                return(Json(new { code = 1, msg = "/Content/Export.xls" }));
            }
            catch (Exception ex)
            {
                return(Json(new { code = 0, msg = ex.Message }));
            }
        }