void exporter_ExcelCellFormatting(object sender, Telerik.WinControls.UI.Export.ExcelML.ExcelCellFormattingEventArgs e) { if (e.GridRowInfoType == typeof(GridViewTableHeaderRowInfo)) { BorderStyles headerBorder = new BorderStyles(); headerBorder.Color = Color.Black; headerBorder.Weight = 2; headerBorder.LineStyle = LineStyle.Continuous; headerBorder.PositionType = PositionType.Bottom; e.ExcelStyleElement.Borders.Add(headerBorder); } else if (e.GridColumnIndex == radGridView1.Columns["SalesLastYear"].Index) { int value = Convert.ToInt32(radGridView1.Rows[e.GridRowIndex].Cells [e.GridColumnIndex].Value); if (value > 1500000) { e.ExcelStyleElement.InteriorStyle.Color = Color.Yellow; e.ExcelStyleElement.AlignmentElement.WrapText = true; } } }
void export_ExcelCellFormatting(object sender, Telerik.WinControls.UI.Export.ExcelML.ExcelCellFormattingEventArgs e) { if (ApplyCellFormatting) { if (ApplyCustomCellFormatting == true) { if (e.GridRowInfoType.Name == "GridViewDataRowInfo") { e.ExcelStyleElement.InteriorStyle.Color = Color.White; e.ExcelStyleElement.InteriorStyle.Pattern = Telerik.WinControls.UI.Export.ExcelML.InteriorPatternType.Solid; int borderWeight = 3; if (e.GridRowIndex > 5) { borderWeight = 1; } e.ExcelStyleElement.Borders.Add(new BorderStyles() { Color = Color.SteelBlue, LineStyle = LineStyle.Continuous, Weight = borderWeight, PositionType = PositionType.Bottom }); e.ExcelStyleElement.Borders.Add(new BorderStyles() { Color = Color.SteelBlue, LineStyle = LineStyle.Continuous, Weight = borderWeight, PositionType = PositionType.Left }); e.ExcelStyleElement.Borders.Add(new BorderStyles() { Color = Color.SteelBlue, LineStyle = LineStyle.Continuous, Weight = borderWeight, PositionType = PositionType.Right }); e.ExcelStyleElement.FontStyle.Bold = true; e.ExcelStyleElement.AlignmentElement.HorizontalAlignment = HorizontalAlignmentType.Center; if (this.Grid.Rows[e.GridRowIndex].Cells[e.GridColumnIndex].Tag != null) { if (this.Grid.Rows[e.GridRowIndex].Cells[e.GridColumnIndex].Tag.ToInt() == Enums.PAYMENT_TYPES.CASH && this.Grid.Rows[e.GridRowIndex].Cells[e.GridColumnIndex].Value.ToDecimal() > 25) { e.ExcelStyleElement.FontStyle.Color = Color.Red; } else if (this.Grid.Rows[e.GridRowIndex].Cells[e.GridColumnIndex].Tag.ToInt() == Enums.PAYMENT_TYPES.CREDIT_CARD || this.Grid.Rows[e.GridRowIndex].Cells[e.GridColumnIndex].Tag.ToInt() == Enums.PAYMENT_TYPES.CREDIT_CARD_PAID) { e.ExcelStyleElement.FontStyle.Color = Color.Green; } else if (this.Grid.Rows[e.GridRowIndex].Cells[e.GridColumnIndex].Tag.ToInt() != Enums.PAYMENT_TYPES.CASH && this.Grid.Rows[e.GridRowIndex].Cells[e.GridColumnIndex].Tag.ToInt() != Enums.PAYMENT_TYPES.CREDIT_CARD && this.Grid.Rows[e.GridRowIndex].Cells[e.GridColumnIndex].Tag.ToInt() != Enums.PAYMENT_TYPES.CREDIT_CARD_PAID) { e.ExcelStyleElement.FontStyle.Color = Color.Blue; } } //if(.v // e.ExcelStyleElement.FontStyle.Color = this.ConditionalFormattingObject.RowForeColor; //if (this.Grid.Columns[e.GridColumnIndex] is GridViewDecimalColumn) // e.ExcelStyleElement.AlignmentElement.HorizontalAlignment = HorizontalAlignmentType.Right; } } else { e.ExcelStyleElement.AlignmentElement.WrapText = false; // e.ExcelStyleElement.FontStyle.Bold = true; if (e.GridRowInfoType.Name == "GridViewTableHeaderRowInfo") { e.ExcelStyleElement.FontStyle.Color = this.HeaderForeColor; e.ExcelStyleElement.FontStyle.Bold = true; e.ExcelStyleElement.InteriorStyle.Pattern = Telerik.WinControls.UI.Export.ExcelML.InteriorPatternType.Solid; e.ExcelStyleElement.InteriorStyle.Color = this.HeaderBackColor; } else if (e.GridRowInfoType.Name == "GridViewDataRowInfo") { if (this.ConditionalFormattingObject != null && this.Grid.Rows[e.GridRowIndex].Cells[this.ConditionalFormattingObject.ConditionFormattingColumnName].Value.ToStr() == this.ConditionalFormattingObject.TValue.ToStr()) { e.ExcelStyleElement.InteriorStyle.Color = this.ConditionalFormattingObject.RowBackColor; e.ExcelStyleElement.InteriorStyle.Pattern = Telerik.WinControls.UI.Export.ExcelML.InteriorPatternType.Solid; e.ExcelStyleElement.FontStyle.Bold = true; e.ExcelStyleElement.FontStyle.Color = this.ConditionalFormattingObject.RowForeColor; } if (this.Grid.Columns[e.GridColumnIndex] is GridViewDecimalColumn) { e.ExcelStyleElement.AlignmentElement.HorizontalAlignment = HorizontalAlignmentType.Right; } } else if (e.GridRowInfoType.Name == "GridViewSummaryRowInfo") { e.ExcelStyleElement.FontStyle.Color = Color.Black; e.ExcelStyleElement.FontStyle.Bold = true; e.ExcelStyleElement.InteriorStyle.Pattern = Telerik.WinControls.UI.Export.ExcelML.InteriorPatternType.Solid; e.ExcelStyleElement.InteriorStyle.Color = Color.Gainsboro; if (this.Grid.Columns[e.GridColumnIndex] is GridViewDecimalColumn) { e.ExcelStyleElement.AlignmentElement.HorizontalAlignment = HorizontalAlignmentType.Right; } } } } cnt++; UpdateProgress(); }