Exemplo n.º 1
0
        public HttpResponseMessage Export()
        {
            #region "实体List数据导出"
            Dictionary <string, string> columnAlias = new Dictionary <string, string>();
            columnAlias.Add("Name", "姓名");
            columnAlias.Add("UserName", "用户名");
            columnAlias.Add("UserPwd", null);
            columnAlias.Add("CreateTime", null);

            return(_service.Export("用户数据导出", columnAlias, "xls"));

            #endregion
            #region "datatable数据导出"
            //DataTable dt = new DataTable();
            //dt.Columns.Add("Name");
            //dt.Columns.Add("UserName");
            //dt.Columns.Add("UserPwd");
            //dt.Columns.Add("CreateTime");
            //dt.Rows.Add(dt.NewRow());
            //dt.Rows.Add(dt.NewRow());
            //dt.Rows[0]["Name"] = "张三";
            //dt.Rows[0]["UserName"] = "******";
            //dt.Rows[0]["UserPwd"] = "123456";
            //dt.Rows[0]["CreateTime"] = "2015-05-26";
            //dt.Rows[1]["Name"] = "李四";
            //dt.Rows[1]["UserName"] = "******";
            //dt.Rows[1]["UserPwd"] = "123456";
            //dt.Rows[1]["CreateTime"] = "2015-05-26";

            //Dictionary<string, string> columnAlias = new Dictionary<string, string>();
            //columnAlias.Add("Name", "姓名");
            //columnAlias.Add("UserName", "用户名");
            //columnAlias.Add("UserPwd", "密码");
            //columnAlias.Add("CreateTime", "创建时间");
            //return Common.CommonClass.ImExPort<Base_UserInfo>.Export("用户数据导出", dt, columnAlias, "xls");
            #endregion
        }