Esempio n. 1
0
        public void Export()
        {
            MDataTable dt = Select(GridConfig.SelectType.Export);

            dt.TableName   = ObjName;
            dt.DynamicData = GridConfig.GetList(ObjName, GridConfig.SelectType.All);
            Dictionary <string, string> formatParas = GridConfig.SetHeaderDescription(dt);                                                                              //格式化列头(描述)(需要修改列头的数据格式)

            KeyValueConfig.FormatNameValue(dt, formatParas, true);                                                                                                      //格式化配置项
            WebHelper.SendFile(KeyValueConfig.GetTableDescription(ObjName, TableName) + "_" + DateTime.Now.ToString("yyyyMMdd") + ".xls", ExcelHelper.CreateExcel(dt)); //ExcelHelper.CreateExcel(dt)
        }
Esempio n. 2
0
        public virtual void Export()
        {
            MDataTable dt = Select(GridConfig.SelectType.Export);

            dt.TableName   = ObjName;
            dt.DynamicData = GridConfig.GetList(ObjName, GridConfig.SelectType.Export);
            Dictionary <string, string> formatParas = GridConfig.GetFormatter(dt); //格式化列头(描述)(需要修改列头的数据格式)

            KeyValueConfig.FormatNameValue(dt, formatParas, true);                 //格式化配置项
            string fix = ExcelHelper.BookType == ExcelHelper.WorkBookType.High ? ".xlsx" : ".xls";

            WebHelper.SendFile(KeyValueConfig.GetTableDescription(ObjName, TableName) + "_" + DateTime.Now.ToString("yyyyMMdd") + fix, ExcelHelper.CreateExcel(dt));//ExcelHelper.CreateExcel(dt)
        }
Esempio n. 3
0
        /// <summary>
        /// 获取Config_Grid的某配置项的脚本
        /// </summary>
        public void GetGridConfigScript()
        {
            string script = SqlScript.GetGridConfigScript(ObjName);
            bool   result = !string.IsNullOrEmpty(script);

            if (result)
            {
                WebHelper.SendFile("sys_Grid配置_" + KeyValueConfig.GetTableDescription(ObjName, TableName) + ".sql", script);
            }
            else
            {
                jsonResult = JsonHelper.OutResult(result, script);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 获取Config_ExcelInfo的某配置项的脚本
        /// </summary>
        public void GetExcelConfigScript()
        {
            string script = SQLScript.GetExcelConfigScript(GetID);
            bool   result = !string.IsNullOrEmpty(script);

            if (result)
            {
                CommonHelper.SendFile("sys_Excel配置_" + KeyValueConfig.GetTableDescription(ObjName, TableName) + ".sql", script);
            }
            else
            {
                jsonResult = JsonHelper.OutResult(result, script);
            }
        }
Esempio n. 5
0
        /// <summary>
        /// 获取导入数据的模板(支持2007以上)
        /// </summary>
        public void ExcelTemplate()
        {
            string path = HttpContext.Current.Server.MapPath("~/Resource/Excel/" + ObjName + ".xls");

            if (!File.Exists(path))
            {
                path = path + "x";
                if (!File.Exists(path))
                {
                    path = HttpContext.Current.Server.MapPath("~/Resource/Excel/" + TableName + ".xls");
                    if (!File.Exists(path))
                    {
                        path = path + "x";
                    }
                }
            }

            MemoryStream ms = null;

            if (File.Exists(path))
            {
                byte[] data = File.ReadAllBytes(path);
                ms = new MemoryStream(data, 0, data.Length, false, true);
            }
            string fix = "_模板";

            if (ms == null)
            {
                fix = "-模板";
                string     objName = ObjName;
                MDataTable dt      = GridConfig.GetList(objName, GridConfig.SelectType.All);//获取所有列的字段名。
                if (dt.Rows.Count > 0)
                {
                    ms = ExcelHelper.CreateExcelHeader(dt, KeyValueConfig.GetValidationData(dt));
                }
            }
            WebHelper.SendFile(KeyValueConfig.GetTableDescription(ObjName, TableName) + fix + Path.GetExtension(path), ms);
        }
Esempio n. 6
0
        /// <summary>
        /// 获取导入数据的模板(支持2007以上)
        /// </summary>
        public void ExcelTemplate()
        {
            string path = HttpContext.Current.Server.MapPath("~/Resource/Excel/" + ObjName + ".xls");

            if (!File.Exists(path))
            {
                path = path + "x";
                if (!File.Exists(path) && ObjName != TableName)
                {
                    path = HttpContext.Current.Server.MapPath("~/Resource/Excel/" + TableName + ".xls");
                    if (!File.Exists(path))
                    {
                        path = path + "x";
                    }
                }
            }

            MemoryStream ms  = null;
            string       fix = ExcelHelper.BookType == ExcelHelper.WorkBookType.High ? ".xlsx" : ".xls";

            if (File.Exists(path))
            {
                byte[] data = File.ReadAllBytes(path);
                ms  = new MemoryStream(data, 0, data.Length, false, true);
                fix = Path.GetExtension(path);
            }
            if (ms == null)
            {
                string     objName = ObjName;
                MDataTable header  = GridConfig.GetList(objName, GridConfig.SelectType.Import);//获取所有列的字段名。
                if (header.Rows.Count > 0)
                {
                    ms = ExcelHelper.CreateExcelHeader(header, KeyValueConfig.GetValidationData(header));
                }
            }
            WebHelper.SendFile(KeyValueConfig.GetTableDescription(ObjName, TableName) + fix, ms);
        }