Exemple #1
0
        private void makeExcel(Telerik.Web.UI.GridExcelBuilder.GridExcelMLWorkBookCreatedEventArgs e)
        {
            int r = 0;

            foreach (Telerik.Web.UI.GridExcelBuilder.RowElement row in e.WorkBook.Worksheets[0].Table.Rows)
            {
                for (int i = 0; i < row.Cells.Count; i++)
                {
                    if (r != 0)
                    {
                        if (r % 2 == 0)
                        {
                            row.Cells[i].StyleValue = "lightBlue";
                        }
                        else
                        {
                            row.Cells[i].StyleValue = "blue";
                        }
                    }
                    else
                    {
                        row.Cells[i].StyleValue = "styleHeader";
                    }
                }
                r++;
            }
            Telerik.Web.UI.GridExcelBuilder.StyleElement styleHeader = new Telerik.Web.UI.GridExcelBuilder.StyleElement("styleHeader");
            styleHeader.InteriorStyle.Pattern = Telerik.Web.UI.GridExcelBuilder.InteriorPatternType.Solid;
            styleHeader.InteriorStyle.Color   = System.Drawing.Color.White;
            styleHeader.FontStyle.FontName    = "Tahoma";
            styleHeader.FontStyle.Bold        = true;
            styleHeader.AlignmentElement.HorizontalAlignment = Telerik.Web.UI.GridExcelBuilder.HorizontalAlignmentType.Center;
            e.WorkBook.Styles.Add(styleHeader);
            Telerik.Web.UI.GridExcelBuilder.StyleElement style = new Telerik.Web.UI.GridExcelBuilder.StyleElement("lightBlue");
            style.InteriorStyle.Pattern = Telerik.Web.UI.GridExcelBuilder.InteriorPatternType.Solid;
            style.InteriorStyle.Color   = System.Drawing.Color.FromArgb(162, 226, 255);
            style.FontStyle.FontName    = "Tahoma";
            style.AlignmentElement.HorizontalAlignment = Telerik.Web.UI.GridExcelBuilder.HorizontalAlignmentType.Center;
            e.WorkBook.Styles.Add(style);
            Telerik.Web.UI.GridExcelBuilder.StyleElement style2 = new Telerik.Web.UI.GridExcelBuilder.StyleElement("blue");
            style2.AlignmentElement.HorizontalAlignment = Telerik.Web.UI.GridExcelBuilder.HorizontalAlignmentType.Center;
            style2.InteriorStyle.Pattern = Telerik.Web.UI.GridExcelBuilder.InteriorPatternType.Solid;
            style2.InteriorStyle.Color   = System.Drawing.Color.FromArgb(217, 243, 255);
            style2.FontStyle.FontName    = "Tahoma";
            e.WorkBook.Styles.Add(style2);
        }
Exemple #2
0
    protected void RadGrid1_ExcelMLExportStyles(object source, GridExportExcelMLStyleCreatedArgs e)
    {
        try
        {
            foreach (Telerik.Web.UI.GridExcelBuilder.StyleElement style in e.Styles)
            {
                if (style.Id == "headerStyle")
                {
                    style.FontStyle.Bold        = true;
                    style.FontStyle.Color       = System.Drawing.Color.CadetBlue;
                    style.InteriorStyle.Color   = System.Drawing.Color.Wheat;
                    style.InteriorStyle.Pattern = Telerik.Web.UI.GridExcelBuilder.InteriorPatternType.Solid;
                }
                else if (style.Id == "itemStyle")
                {
                    style.InteriorStyle.Color   = System.Drawing.Color.WhiteSmoke;
                    style.InteriorStyle.Pattern = Telerik.Web.UI.GridExcelBuilder.InteriorPatternType.Solid;
                }
                else if (style.Id == "alternatingItemStyle")
                {
                    style.InteriorStyle.Color   = System.Drawing.Color.LightGray;
                    style.InteriorStyle.Pattern = Telerik.Web.UI.GridExcelBuilder.InteriorPatternType.Solid;
                }
            }

            Telerik.Web.UI.GridExcelBuilder.StyleElement myStyle = new Telerik.Web.UI.GridExcelBuilder.StyleElement("MyCustomStyle");
            myStyle.FontStyle.Bold        = true;
            myStyle.FontStyle.Italic      = true;
            myStyle.InteriorStyle.Color   = System.Drawing.Color.LightGray;
            myStyle.InteriorStyle.Pattern = Telerik.Web.UI.GridExcelBuilder.InteriorPatternType.Solid;
            e.Styles.Add(myStyle);
        }

        catch (Exception ex)
        {
            SMHR.BLL.Error_Log(Session["USER_ID"].ToString(), ex.TargetSite.ToString(), ex.Message.Replace("'", "''"), "frm_esiimport", ex.StackTrace, DateTime.Now);
            Response.Redirect("~/Frm_ErrorPage.aspx");
        }
    }