如题

解决方案 »

  1.   

    Response.Clear();
                Response.Buffer = true;
                Response.Charset = "GB2312";
                string _today = string.Format("{0:yyyyMMdd}", DateTime.Now.Date);
                if (ViewState["leaderName"] == null)
                {
                    Response.AppendHeader("Content-Disposition", "attachment;filename=" + Server.UrlEncode("领导行程") + "-" + _today + ".xls");
                }
                else
                {
                    Response.AppendHeader("Content-Disposition", "attachment;filename=" + Server.UrlEncode("领导行程") + "-" + Server.UrlEncode(ViewState["leaderName"].ToString()) + "-" + _today + ".xls");
                }
                Response.ContentEncoding = System.Text.Encoding.UTF7;
                Response.ContentType = "application/ms-excel";//设置输出文件类型为excel文件。 
                System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
                System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);            ///
                Repeater rep = rep_Jourey;
                rep.Controls[0].FindControl("delHead").Visible = false;
                rep.Controls[0].FindControl("modifyHead").Visible = false;
                rep.Controls[0].FindControl("addHead").Visible = false;
                //隐藏修改 删除
                //if (!Bussiness.IsManager(this))
                //{           
                foreach (RepeaterItem item in rep.Items)
                {
                    if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem)
                    {
                        HtmlTableCell cell1 = (HtmlTableCell)item.FindControl("null1");
                        cell1.Attributes.Remove("style");                    HtmlTableCell cell2 = (HtmlTableCell)item.FindControl("null2");
                        cell2.Attributes.Remove("style");                    HtmlTableCell cell3 = (HtmlTableCell)item.FindControl("null3");
                        cell3.Attributes.Remove("style");                    HtmlTableCell cell4 = (HtmlTableCell)item.FindControl("null4");
                        cell4.Attributes.Remove("style");                    HtmlTableCell cell5 = (HtmlTableCell)item.FindControl("null5");
                        cell5.Attributes.Remove("style");                    HtmlTableCell cell6 = (HtmlTableCell)item.FindControl("null6");
                        cell6.Attributes.Remove("style");                    HtmlTableCell cell7 = (HtmlTableCell)item.FindControl("null7");
                        cell7.Attributes.Remove("style");                    HtmlTableCell cell8 = (HtmlTableCell)item.FindControl("null8");
                        cell8.Attributes.Remove("style");                    HtmlTableCell cell9 = (HtmlTableCell)item.FindControl("null9");
                        cell9.Attributes.Remove("style");                    HtmlTableCell cell10 = (HtmlTableCell)item.FindControl("null10");
                        cell10.Attributes.Remove("style");                    HtmlTableCell cell11 = (HtmlTableCell)item.FindControl("null11");
                        cell11.Attributes.Remove("style");                    //item.FindControl("null1").Visible = false;
                        //item.FindControl("null2").Visible = false;
                        //item.FindControl("null3").Visible = false;
                        //item.FindControl("null4").Visible = false;
                        //item.FindControl("null5").Visible = false;
                        //item.FindControl("null6").Visible = false;
                        //item.FindControl("null7").Visible = false;
                        //item.FindControl("null8").Visible = false;
                        item.FindControl("null9").Visible = false;
                        item.FindControl("null10").Visible = false;
                        
                        item.FindControl("hideID").Visible = false;
                        item.FindControl("td_add").Visible = false;
                        Repeater rep_in = (Repeater)item.FindControl("rep_in");
                        foreach (RepeaterItem itemIn in rep_in.Items)
                        {
                            if (itemIn.ItemType == ListItemType.Item || itemIn.ItemType == ListItemType.AlternatingItem)
                            {
                                itemIn.FindControl("del").Visible = false;
                                itemIn.FindControl("modify").Visible = false;
                                itemIn.FindControl("img").Visible = false;
                            }
                        }
                    }
                }
                //}
                rep.RenderControl(oHtmlTextWriter);
                ///            Response.Output.Write(oStringWriter.ToString());
                Response.Flush();
                Response.End();