当前位置: 首页>>代码示例>>C#>>正文


C# Table.RenderControl方法代码示例

本文整理汇总了C#中Table.RenderControl方法的典型用法代码示例。如果您正苦于以下问题:C# Table.RenderControl方法的具体用法?C# Table.RenderControl怎么用?C# Table.RenderControl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Table的用法示例。


在下文中一共展示了Table.RenderControl方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Export

    /// <summary>
    /// 
    /// </summary>
    /// <param name="sw"></param>
    public static void Export(StringWriter sw, GridView gv)
    {
        using (HtmlTextWriter htw = new HtmlTextWriter(sw))
        {
            //  Create a table to contain the grid
            Table table = new Table();

            //  include the gridline settings
            table.GridLines = gv.GridLines;

            //  add the header row to the table
            if (gv.HeaderRow != null)
            {

                table.Rows.Add(gv.HeaderRow);
            }

            //  add each of the data rows to the table
            foreach (GridViewRow row in gv.Rows)
            {

                table.Rows.Add(row);
            }

            //  add the footer row to the table
            if (gv.FooterRow != null)
            {

                table.Rows.Add(gv.FooterRow);
            }

            //  render the table into the htmlwriter
            table.RenderControl(htw);
        }
    }
开发者ID:manivts,项目名称:impexcubeapp,代码行数:39,代码来源:NewExportGridViewToExcelClass.cs

示例2: Export

    public static void Export(string fileName, GridView gv, string title)
    {
        HttpContext.Current.Response.Clear();
        HttpContext.Current.Response.AddHeader(
        "content-disposition", string.Format("attachment; filename={0}", fileName));
        HttpContext.Current.Response.ContentType = "application/ms-excel";
        HttpContext.Current.Response.Charset = "utf-8";

        HttpContext.Current.Response.Write("<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/></head><body>");

        using (StringWriter sw = new StringWriter())
        {
            using (HtmlTextWriter htw = new HtmlTextWriter(sw))
            {
                htw.WriteLine("<h1>" + title + "</h1>");

                // Create a form to contain the grid
                Table table = new Table();

                table.GridLines = gv.GridLines;

                // add the header row to the table
                if (gv.HeaderRow != null)
                {
                    GridViewExportUtil.PrepareControlForExport(gv.HeaderRow);
                    table.Rows.Add(gv.HeaderRow);
                }

                // add each of the data rows to the table
                foreach (GridViewRow row in gv.Rows)
                {
                    GridViewExportUtil.PrepareControlForExport(row);
                    table.Rows.Add(row);
                }

                // add the footer row to the table
                if (gv.FooterRow != null)
                {
                    GridViewExportUtil.PrepareControlForExport(gv.FooterRow);
                    table.Rows.Add(gv.FooterRow);
                }

                // render the table into the htmlwriter
                table.RenderControl(htw);

                // render the htmlwriter into the response
                HttpContext.Current.Response.Write(sw.ToString());
                HttpContext.Current.Response.Write("</body></html>");
                HttpContext.Current.Response.End();
            }
        }
    }
开发者ID:an-kir,项目名称:List-Of-Students,代码行数:52,代码来源:WebForm1.aspx.cs

示例3: Export

    /// <summary>
    /// 
    /// </summary>
    /// <param name="fileName"></param>
    /// <param name="gv"></param>
    public static void Export(string fileName, GridView gv)
    {
        HttpContext.Current.Response.Clear();
        HttpContext.Current.Response.Buffer = false;
        HttpContext.Current.Response.Charset = "GB2312";
        HttpContext.Current.Response.AddHeader(
            "content-disposition", string.Format("attachment; filename={0}", fileName));
        HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
        HttpContext.Current.Response.ContentType = "application/ms-excel";
        HttpContext.Current.Response.Write("<meta http-equiv=Content-Type content=\"text/html; charset=GB2312\">");

        using (StringWriter sw = new StringWriter())
        {
            using (HtmlTextWriter htw = new HtmlTextWriter(sw))
            {
                //  Create a table to contain the grid
                Table table = new Table();

                //  include the gridline settings
                table.GridLines = gv.GridLines;

                //  add the header row to the table
                if (gv.HeaderRow != null)
                {
                    GridViewExportUtil.PrepareControlForExport(gv.HeaderRow);
                    table.Rows.Add(gv.HeaderRow);
                }

                //  add each of the data rows to the table
                foreach (GridViewRow row in gv.Rows)
                {
                    GridViewExportUtil.PrepareControlForExport(row);
                    table.Rows.Add(row);
                }

                //  add the footer row to the table
                if (gv.FooterRow != null)
                {
                    GridViewExportUtil.PrepareControlForExport(gv.FooterRow);
                    table.Rows.Add(gv.FooterRow);
                }

                //  render the table into the htmlwriter
                table.RenderControl(htw);

                //  render the htmlwriter into the response
                HttpContext.Current.Response.Write(sw.ToString());
                HttpContext.Current.Response.End();
            }
        }
    }
开发者ID:porter1130,项目名称:MOSSArt,代码行数:56,代码来源:GridViewExportUtil.cs

示例4: ExceleAktar

    /// <summary>
    /// 
    /// </summary>
    /// <param name="fileName"></param>
    /// <param name="gv"></param>
    public void ExceleAktar(DataTable Tablo, string fileName, GridLines Kenarlik)
    {
        HttpContext.Current.Response.Clear();
        HttpContext.Current.Response.AddHeader(
            "content-disposition", string.Format("attachment; filename={0}", fileName));
        HttpContext.Current.Response.ContentType = "application/ms-excel";

        GridView gv = new GridView();
        gv.DataSource = Tablo;
        gv.DataBind();
        using(StringWriter sw = new StringWriter())
        {
            using(HtmlTextWriter htw = new HtmlTextWriter(sw))
            {
                //  Create a table to contain the grid
                Table table = new Table();

                //  include the gridline settings
                table.GridLines = Kenarlik;

                //  add the header row to the table
                if(gv.HeaderRow != null)
                {
                    TuaGridViewExcelExport.PrepareControlForExport(gv.HeaderRow);
                    table.Rows.Add(gv.HeaderRow);
                }

                //  add each of the data rows to the table
                foreach(GridViewRow row in gv.Rows)
                {
                    TuaGridViewExcelExport.PrepareControlForExport(row);
                    table.Rows.Add(row);
                }

                //  add the footer row to the table
                if(gv.FooterRow != null)
                {
                    TuaGridViewExcelExport.PrepareControlForExport(gv.FooterRow);
                    table.Rows.Add(gv.FooterRow);
                }

                //  render the table into the htmlwriter
                table.RenderControl(htw);
                //  render the htmlwriter into the response
                HttpContext.Current.Response.Write(RecursiveTranslateAjax(sw.ToString()));
                HttpContext.Current.Response.End();
            }
        }
    }
开发者ID:tbalci,项目名称:GalataSozluk,代码行数:54,代码来源:GridViewExcelExport.cs

示例5: Export

    public static void Export(string fileName, GridView gv, bool includeGridLines)
    {
        HttpContext.Current.Response.Clear();
        HttpContext.Current.Response.AddHeader(
            "content-disposition", string.Format("attachment; filename={0}", fileName));
        HttpContext.Current.Response.ContentType = "application/ms-excel";

        using (StringWriter sw = new StringWriter())
        {
            using (HtmlTextWriter htw = new HtmlTextWriter(sw))
            {
                //  Create a form to contain the grid
                Table table = new Table();
                if (includeGridLines)
                {
                    table.GridLines = gv.GridLines;
                }

                //  add the header row to the table
                if (gv.HeaderRow != null)
                {
                    GridViewExportUtil.PrepareControlForExport(gv.HeaderRow);
                    table.Rows.Add(gv.HeaderRow);
                }

                //  add each of the data rows to the table
                foreach (GridViewRow row in gv.Rows)
                {
                    GridViewExportUtil.PrepareControlForExport(row);
                    table.Rows.Add(row);
                }

                //  add the footer row to the table
                if (gv.FooterRow != null)
                {
                    GridViewExportUtil.PrepareControlForExport(gv.FooterRow);
                    table.Rows.Add(gv.FooterRow);
                }

                //  render the table into the htmlwriter
                table.RenderControl(htw);

                //  render the htmlwriter into the response
                HttpContext.Current.Response.Write(sw.ToString());
                HttpContext.Current.Response.End();
            }
        }
    }
开发者ID:srisai339,项目名称:LoveJourney_Working,代码行数:48,代码来源:GridViewExportUtil.cs

示例6: Export

    public static void Export(string fileName, GridView gv)
    {
        string style = @"<style> .text { mso-number-format:\@; } </style> ";
        HttpContext.Current.Response.Clear();
        HttpContext.Current.Response.AddHeader(
        "content-disposition", string.Format("attachment; filename={0}", fileName));
        HttpContext.Current.Response.ContentType = "application/ms-excel";

        using (StringWriter sw = new StringWriter())
        {
            using (HtmlTextWriter htw = new HtmlTextWriter(sw))
            {
                // Create a form to contain the grid
                Table table = new Table();

                // add the header row to the table
                if (gv.HeaderRow != null)
                {
                    PrepareControlForExport(gv.HeaderRow);
                    table.Rows.Add(gv.HeaderRow);
                }

                // add each of the data rows to the table
                foreach (GridViewRow row in gv.Rows)
                {
                    PrepareControlForExport(row);
                    table.Rows.Add(row);
                }

                // add the footer row to the table
                if (gv.FooterRow != null)
                {
                    PrepareControlForExport(gv.FooterRow);
                    table.Rows.Add(gv.FooterRow);
                }

                // render the table into the htmlwriter
                table.RenderControl(htw);
                HttpContext.Current.Response.Write(style);
                HttpContext.Current.Response.Write(sw.ToString());
                HttpContext.Current.Response.End();
            }
        }
    }
开发者ID:srisai339,项目名称:LoveJourney_Working,代码行数:44,代码来源:Users.aspx.cs

示例7: ShowSiteActivity


//.........这里部分代码省略.........
                                    break;
                                }
                            }
                            catch
                            {
                                break;
                            }

                            rowtbl3[k] = new TableRow();
                            Pageinnertbl[j].Controls.Add(rowtbl3[k]);
                            celltbl31[k] = new TableCell();
                            celltbl32[k] = new TableCell();
                            celltbl33[k] = new TableCell();
                            celltbl34[k] = new TableCell();

                            if (Convert.ToBoolean((Convert.ToInt32(k) % 2)))
                            {
                                celltbl31[k].BackColor = System.Drawing.Color.LavenderBlush;
                                celltbl32[k].BackColor = System.Drawing.Color.LavenderBlush;
                                celltbl33[k].BackColor = System.Drawing.Color.LavenderBlush;
                                celltbl34[k].BackColor = System.Drawing.Color.LavenderBlush;
                            }
                            else
                            {
                                celltbl31[k].BackColor = System.Drawing.Color.LightCyan;
                                celltbl32[k].BackColor = System.Drawing.Color.LightCyan;
                                celltbl33[k].BackColor = System.Drawing.Color.LightCyan;
                                celltbl34[k].BackColor = System.Drawing.Color.LightCyan;
                            }
                            lblPg1[k] = new Label();
                            lblPg2[k] = new Label();
                            lblPg3[k] = new Label();
                            lblPg4[k] = new Label();
                            //lblPg1(i).Text = aFolder.Item(j - 1).item(i)("PageName")  'data(i)("PageName")
                            //if (((Collection)((ArrayList)aFolder[j - 1])[i])["FolderName"] != aPath[j - 1])

                            lblPg1[k].Text = (((Collection)((ArrayList)aFolder[j - 1])[k])["PageName"]).ToString(); //data(i)("PageName")
                            lblPg2[k].Text = (((Collection)((ArrayList)aFolder[j - 1])[k])["Updates"]).ToString(); //data(i)("Updates")
                            lblPg3[k].Text = (string)("&#160;" + ((Collection)((ArrayList)aFolder[j - 1])[k])["LastUpdated"]).ToString(); //data(i)("LastUpdated")
                            lblPg4[k].Text = (string)("&#160;" + ((Collection)((ArrayList)aFolder[j - 1])[k])["UserName"]).ToString(); //data(i)("UserName")
                            celltbl31[k].Controls.Add(lblPg1[k]);
                            celltbl32[k].Controls.Add(lblPg2[k]);
                            celltbl33[k].Controls.Add(lblPg3[k]);
                            celltbl34[k].Controls.Add(lblPg4[k]);

                            rowtbl3[k].Controls.Add(celltbl31[k]);
                            rowtbl3[k].Controls.Add(celltbl32[k]);
                            rowtbl3[k].Controls.Add(celltbl33[k]);
                            rowtbl3[k].Controls.Add(celltbl34[k]);
                        }
                    }

                    cellPage[j].Controls.Add(Pageinnertbl[j]);
                    rowPage[j].Controls.Add(cellPage[j]);

                    celltbl211[j].Controls.Add(lblFolderHeader1[j]);
                    celltbl212[j].Controls.Add(lblFolderHeader2[j]);
                    celltbl213[j].Controls.Add(lblFolderHeader3[j]);
                    celltbl221[j].Controls.Add(lblTotalUpdated[j]);
                    celltbl222[j].Controls.Add(lblPagesUpdated[j]);
                    celltbl223[j].Controls.Add(lblTotalPages[j]);
                    folderinnertbl[j].Controls.Add(rowtbl12[j]);
                    rowtbl12[j].Controls.Add(celltbl211[j]);
                    rowtbl12[j].Controls.Add(celltbl212[j]);
                    rowtbl12[j].Controls.Add(celltbl213[j]);
                    folderinnertbl[j].Controls.Add(rowtbl22[j]);
                    rowtbl22[j].Controls.Add(celltbl221[j]);
                    rowtbl22[j].Controls.Add(celltbl222[j]);
                    rowtbl22[j].Controls.Add(celltbl223[j]);
                    cellfolder[j].Controls.Add(folderinnertbl[j]);
                    rowfolder[j].Controls.Add(cellfolder[j]);

                    cellPath[j].Controls.Add(lblPath[j]);
                    rowPath[j].Controls.Add(cellPath[j]);

                    cellMain.Controls.Add(tblrep[j]);
                    rowMain.Controls.Add(cellMain);

                }
            }
            //tables of reports added to the placeholder phUpdateActivity
            phUpdateActivity.Controls.Clear();
            phUpdateActivity.Controls.Add(main);
            phUpdateActivity.Visible = true;
            tr_phUpdateActivity.Visible = true;

            //read the tables of reports in HTML.
            //store it in the member variable for export task.
            //store in the hidden field for email task.
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            System.IO.StringWriter stringWrite = new System.IO.StringWriter(sb);
            HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
            string siteRptHtml = "";
            main.RenderControl(htmlWrite);
            _ReportTableHtml = sb.ToString();
            siteRptHtml = "<input id=\"siteRptHtml\" type=\"hidden\" name=\"siteRptHtml\" value=\"" + Ektron.Cms.Common.EkFunctions.HtmlEncode(_ReportTableHtml) + "\"/>";
            siteRptHtml = siteRptHtml + "<script type=\"text/javascript\">setDisplayMode(\'" + _ReportDisplay + "\');</script>";
            SiteActivityHtml.Text = siteRptHtml;
        }
    }
开发者ID:jaytem,项目名称:minGit,代码行数:101,代码来源:reports.aspx.cs

示例8: ExportExcel

    /// <summary>
    /// Export excel with HTML format
    /// </summary>
    /// <param name="response">Current page response</param>
    /// <param name="fileName">export file name</param>
    /// <param name="tb">web html table</param>
    public static void ExportExcel(HttpResponse response, string fileName, Table tb)
    {
        try
        {
            response.Clear();
            response.ClearContent();
            response.ClearHeaders();
            response.Buffer = true;
            response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";

            response.AppendHeader("Content-Disposition", string.Format("attachment; filename={0}", fileName));

            response.Charset = "utf-8";
            response.ContentEncoding = System.Text.Encoding.UTF8;
            response.BinaryWrite(System.Text.Encoding.UTF8.GetPreamble());

            System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
            System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
            tb.RenderControl(oHtmlTextWriter);
            response.Write(@"<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0 Transitional//EN"">");
            response.Write(AddExcelStyling());
            string style = @"<style> .text { mso-number-format:\@; } </style>";
            response.Write(style);
            response.Write(oStringWriter.ToString());

            response.End();
        }
        catch (Exception ex)
        {
            Pollinator.Common.Logger.Error("Error occured at " + typeof(ImportExportUltility).Name + " ExportExcel().:", ex);
            response.End();
        }
    }
开发者ID:nazrulcse,项目名称:pollinatror,代码行数:39,代码来源:ImportExportUltility.cs

示例9: ExportExcell

    /// <summary>
    /// 
    /// </summary>
    /// <param name="fileName"></param>.
    /// <param name="gv"></param>
    public static void ExportExcell(string fileName, GridView gv)
    {
        HttpContext.Current.Response.Clear();
        HttpContext.Current.Response.Buffer = true;

        HttpContext.Current.Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", fileName));
        HttpContext.Current.Response.Charset = "";
        HttpContext.Current.Response.ContentType = "application/vnd.ms-excel";
        StringWriter sw = new StringWriter();
        HtmlTextWriter hw = new HtmlTextWriter(sw);

        //PrepareForExport(gv);
        //PrepareForExport(GridView1);

        Table tb = new Table();
        TableRow tr1 = new TableRow();
        TableCell cell1 = new TableCell();
        cell1.Controls.Add(gv);
        tr1.Cells.Add(cell1);
        //TableCell cell3 = new TableCell();
        //cell3.Controls.Add(GridView1);
        TableCell cell2 = new TableCell();
        cell2.Text = "&nbsp;";
        //if (rbPreference.SelectedValue == "2")
        //{
        //tr1.Cells.Add(cell2);
        //tr1.Cells.Add(cell3);
        //tb.Rows.Add(tr1);
        //}
        //else
        //{
        TableRow tr2 = new TableRow();
        tr2.Cells.Add(cell2);
        //TableRow tr3 = new TableRow();
        //tr3.Cells.Add(cell3);
        tb.Rows.Add(tr1);
        tb.Rows.Add(tr2);
        //tb.Rows.Add(tr3);
        //}
          tb.RenderControl(hw);

        //style to format numbers to string
        string style = @"<style> .textmode { mso-number-format:\@; } </style>";
        HttpContext.Current.Response.Write(style);
        HttpContext.Current.Response.Output.Write(sw.ToString());
        HttpContext.Current.Response.Flush();
        HttpContext.Current.Response.End();
    }
开发者ID:manivts,项目名称:impexcubeapp,代码行数:53,代码来源:GridViewExportDet.cs

示例10: ExportWord

        protected void ExportWord(GridView gridView)
        {
            HttpContext.Current.Response.Clear();
            System.Web.HttpContext curContext = System.Web.HttpContext.Current;
            curContext.Response.AddHeader("content-disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode("StaffEvaluation.doc"));

            HttpContext.Current.Response.ContentType = "application/ms-word";

            //  Create a table to contain the grid
            Table table = new Table();

            //  include the gridline settings
            table.GridLines = gridView.GridLines;

            //  add the header row to the table
            if (gridView.HeaderRow != null)
            {
                PrepareControlForExport(gridView.HeaderRow);
                gridView.HeaderRow.Style.Add("background", "black");
                table.Rows.Add(gridView.HeaderRow);
            }

            //  add each of the data rows to the table

            foreach (GridViewRow row in gridView.Rows)
            {
                PrepareControlForExport(row);
                table.Rows.Add(row);
            }

            //  add the footer row to the table
            if (gridView.FooterRow != null)
            {
                PrepareControlForExport(gridView.FooterRow);
                table.Rows.Add(gridView.FooterRow);
            }

            for (int i = 0; i <= gridView.Rows.Count; i++)
            {
                table.Rows[i].Cells[0].Visible = false;
            }

            using (StringWriter stringWriter = new StringWriter())
            {
                using (HtmlTextWriter htmlWriter = new HtmlTextWriter(stringWriter))
                {
                    //  render the table into the htmlwriter
                    table.RenderControl(htmlWriter);

                    //  render the htmlwriter into the response
                    curContext.Response.Write(stringWriter.ToString());
                    curContext.Response.End();
                }
            }
        }
开发者ID:kaungs542,项目名称:appraisal-mp15,代码行数:55,代码来源:ViewAppraisalAllHistory.aspx.cs

示例11: Export

    /// <summary>
    /// 
    /// </summary>
    /// <param name="fileName"></param>
    /// <param name="gv"></param>
    public static void Export(string fileName, string title,  GridView gv)
    {
        HttpContext.Current.Response.Clear();
        HttpContext.Current.Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", fileName));
        HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);
        HttpContext.Current.Response.ContentType = "application/ms-excel";
        //HttpContext.Current.Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
              
        using (StringWriter sw = new StringWriter())
        {
            using (HtmlTextWriter htw = new HtmlTextWriter(sw))
            {
                //  Create a form to contain the grid
                Table table = new Table();
                table.GridLines = gv.GridLines;

                //  add the header row to the table
                if (gv.HeaderRow != null)
                {
                    gv.HeaderRow.Attributes.Add("class", "header_bg");                     
                    GridViewExportUtil.PrepareControlForExport(gv.HeaderRow); 
                    table.Rows.Add(gv.HeaderRow);
                }

                //  add each of the data rows to the table
                foreach (GridViewRow row in gv.Rows)
                {
                    row.Attributes.Add("class", "sborder"); 
                    GridViewExportUtil.PrepareControlForExport(row);
                    table.Rows.Add(row);
                   
                }

                //  add the footer row to the table
                if (gv.FooterRow != null)
                {
                    GridViewExportUtil.PrepareControlForExport(gv.FooterRow);
                    table.Rows.Add(gv.FooterRow);
                }

                //Color Setttings
                
                //gv.BackColor = System.Drawing.Color.AliceBlue;
                //gv.CellPadding = 50;
                //gv.CellSpacing = 10;
                //gv.CaptionAlign = TableCaptionAlign.Right;
                //gv.HeaderStyle.BackColor = System.Drawing.Color.Black;
                //gv.HeaderStyle.ForeColor = System.Drawing.Color.White;

                htw.WriteLine("<br/><center><span class='heading'>" + title + "<span></center><br/><br/><br/>");

                //htw.WriteLine("<br/><center><b><font size='5' color='#800000'>" + title + "</font></b></center><br/><br/><br/>");
                //  render the table into the htmlwriter
                table.RenderControl(htw);

                //  render the htmlwriter into the response  
                
                HttpContext.Current.Response.Write("<html xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:x=\"urn:schemas-microsoft-com:office:excel\"  xmlns=\"http://www.w3.org/TR/REC-html40\">");
                HttpContext.Current.Response.Write("<head>");
                HttpContext.Current.Response.Write("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">");
                HttpContext.Current.Response.Write("<meta name=ProgId content=Excel.Sheet>");
                HttpContext.Current.Response.Write("<meta name=Generator content=\"Microsoft Excel 11\">");
                HttpContext.Current.Response.Write("<style>");               
                HttpContext.Current.Response.Write(".heading{background-color:#C0C0C0;font:bold 30px 'Times New Roman,Times,Helvetica Neue,Lucida Grande,Helvetica', Arial, Verdana, serif';text-transform:uppercase;color:#800000;}.header_bg{color:#800000;background-color:#C0C0C0;border:1px Solid #000000;} .sborder { color : #000000;border : 1px Solid #000000; background-color:lightyellow;}");
                HttpContext.Current.Response.Write("<!--table @page{} -->");
                HttpContext.Current.Response.Write("</style>");
                HttpContext.Current.Response.Write("<!--[if gte mso 9]><xml>");
                HttpContext.Current.Response.Write("<x:ExcelWorkbook>");
                HttpContext.Current.Response.Write("<x:ExcelWorksheets><x:ExcelWorksheet>");
                HttpContext.Current.Response.Write("<x:Name>"+title+"</x:Name>");
                HttpContext.Current.Response.Write("<x:WorksheetOptions><x:Panes></x:Panes></x:WorksheetOptions>");
                HttpContext.Current.Response.Write("</x:ExcelWorksheet></x:ExcelWorksheets>");
                HttpContext.Current.Response.Write("</x:ExcelWorkbook>");
                HttpContext.Current.Response.Write("</xml>");
                HttpContext.Current.Response.Write("<![endif]-->");
                HttpContext.Current.Response.Write("</head>"); 
                HttpContext.Current.Response.Write("<BODY>");    
                HttpContext.Current.Response.Write(sw.ToString());
                HttpContext.Current.Response.Write("</BODY>");
                HttpContext.Current.Response.Write("</HTML>");
                HttpContext.Current.Response.End();
            }
        }
    }
开发者ID:jackiechou,项目名称:thegioicuaban.com,代码行数:89,代码来源:GridViewExportUtil.cs

示例12: Export2Excel

    /// <summary>
    /// 
    /// </summary>
    /// <param name="fileName"></param>
    /// <param name="gv"></param>
    public static void Export2Excel(string fileName, GridView gv, ArrayList removeColumnslistIndex, ArrayList msoNumberAsTextColumnListIndex, bool isFooterIncluded)
    {
        if (removeColumnslistIndex != null)
        {
            for (int j = 0; j < removeColumnslistIndex.Count; j++)
            {
                if (gv.HeaderRow != null)
                {
                    gv.HeaderRow.Cells[Convert.ToInt32(removeColumnslistIndex[j])].Visible = false;
                }

                for (int i = 0; i < gv.Rows.Count; i++)
                {
                    gv.Rows[i].Cells[Convert.ToInt32(removeColumnslistIndex[j])].Visible = false;
                }

                if (gv.FooterRow != null)
                {
                    gv.FooterRow.Cells[Convert.ToInt32(removeColumnslistIndex[j])].Visible = false;
                }
            }
        }
        
        HttpContext.Current.Response.Clear();
        HttpContext.Current.Response.AddHeader(
            "content-disposition", string.Format("attachment; filename={0}", fileName));
        HttpContext.Current.Response.ContentType = "application/ms-excel";

        using (StringWriter sw = new StringWriter())
        {
            using (HtmlTextWriter htw = new HtmlTextWriter(sw))
            {
                //  Create a table to contain the grid
                Table table = new Table();

                //  include the gridline settings
                table.GridLines = gv.GridLines;

                //  add the header row to the table
                if (gv.HeaderRow != null)
                {
                    GridViewExportUtil.PrepareControlForExport(gv.HeaderRow);
                    table.Rows.Add(gv.HeaderRow);
                }

                //  add each of the data rows to the table
                foreach (GridViewRow row in gv.Rows)
                {
                    GridViewExportUtil.PrepareControlForExport(row);

                    // Format number as text for MSO
                    if ((msoNumberAsTextColumnListIndex != null) && (msoNumberAsTextColumnListIndex.Count > 0))
                    {
                        for (int i = 0; i < msoNumberAsTextColumnListIndex.Count; i++)
                        {
                            int col = (int)msoNumberAsTextColumnListIndex[i];
                            if ((0 <= col) && (col < row.Cells.Count))
                            {
                                row.Cells[col].Style.Add("mso-number-format", @"\@");
                                //row.Cells[col].Style.Add("background-color", "#C2D69B");
                            }
                        }
                    }

                    table.Rows.Add(row);
                }

                //  add the footer row to the table
                if ((isFooterIncluded) && (gv.FooterRow != null))
                {
                    GridViewExportUtil.PrepareControlForExport(gv.FooterRow);
                    table.Rows.Add(gv.FooterRow);
                }

                //  render the table into the htmlwriter
                table.RenderControl(htw);

                //  render the htmlwriter into the response
                HttpContext.Current.Response.Write(sw.ToString());
                HttpContext.Current.Response.End();
            }
        }
    }
开发者ID:tmthang-bi,项目名称:BrokerManager,代码行数:88,代码来源:GridViewExportUtil.cs

示例13: GenOuterHtml

    public static string GenOuterHtml( Table myTbl)
    {
        if (myTbl == null) return string.Empty;

        System.IO.StringWriter mySw = new System.IO.StringWriter();
        HtmlTextWriter myHw = new HtmlTextWriter(mySw);
        myTbl.RenderControl(myHw);
        return mySw.ToString();
    }
开发者ID:quangtrung00,项目名称:QCLogBlook,代码行数:9,代码来源:PccRow.cs


注:本文中的Table.RenderControl方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。