Exemplo n.º 1
0
        public DataTable CreateExcelData(string id)
        {
            DataTable ExcelData = new DataTable();

            ExcelData.Columns.Add("活动标题", typeof(string));
            ExcelData.Columns.Add("报名姓名", typeof(string));
            ExcelData.Columns.Add("性别", typeof(string));
            ExcelData.Columns.Add("联系方式", typeof(string));
            ExcelData.Columns.Add("报名昵称", typeof(string));
            ExcelData.Columns.Add("最后更新时间", typeof(string));

            ParamsHelper parms    = new ParamsHelper();
            string       sqlWhere = " AND asu.ActivityId = @ActivityId ";
            SqlParameter parm     = new SqlParameter("@ActivityId", SqlDbType.UniqueIdentifier);

            parm.Value = Guid.Parse(id);
            parms.Add(parm);
            ActivitySignUp bll = new ActivitySignUp();
            DataSet        ds  = bll.ExportExcel(sqlWhere, parms == null ? null : parms.ToArray());

            if (ds == null)
            {
                return(null);
            }

            foreach (DataRow row in ds.Tables[0].Rows)
            {
                DataRow NewRow = ExcelData.NewRow();
                NewRow["活动标题"]   = row["Title"].ToString();
                NewRow["报名姓名"]   = row["UserName"].ToString();
                NewRow["性别"]     = row["Sex"].ToString();
                NewRow["联系方式"]   = row["MobilePhone"].ToString();
                NewRow["报名昵称"]   = row["Nickname"].ToString();
                NewRow["最后更新时间"] = row["LastUpdatedDate"].ToString();

                ExcelData.Rows.Add(NewRow);
            }
            return(ExcelData);
        }