导出EXCEL时,显示GRID颜色,GRID颜色的设置
#region 根据差量值显示不同的背景色 /// <summary> /// 根据差量值显示不同的背景色 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// private void gvRM_ALARM_INFO_RowCellStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowCellStyleEventArgs e) { if (gvRM_ALARM_INFO.GetRow(e.RowHandle) == null) { return; } else { //七日用量 string strSeven = string.Empty; //五日差量 string strDiffFiveD = string.Empty; //七日差量 string strDiffSevenD = string.Empty; //十五日差量 string strDiffFifD = string.Empty; //五日差量小于0的显示红色 if (e.Column.FieldName == "DiffFiveD") { if (e.CellValue == null || string.IsNullOrEmpty(e.CellValue.ToString())) { strDiffFiveD = "0"; } else { strDiffFiveD = e.CellValue.ToString(); } if (double.Parse(strDiffFiveD) < 0) { e.Appearance.BackColor = Color.Red; } } //七日差量小于七日用量的20%的显示为绿色 if (e.Column.FieldName == "DiffSevenD") { strSeven = gvRM_ALARM_INFO.GetRowCellValue(e.RowHandle, "SPACE3").ToString(); if (string.IsNullOrEmpty(strSeven)) { strSeven = "0"; } if (e.CellValue == null && string.IsNullOrEmpty(e.CellValue.ToString())) { strDiffSevenD = "0"; } else { strDiffSevenD = e.CellValue.ToString(); } if ((Math.Abs(double.Parse(strDiffSevenD)) / double.Parse(strSeven)) < 0.2) { e.Appearance.BackColor = Color.Green; } else { e.Appearance.BackColor = Color.Yellow; } } //十五日差量大于0的显示为红色 if (e.Column.FieldName == "DiffFifD") { if (e.CellValue == null || string.IsNullOrEmpty(e.CellValue.ToString())) { strDiffFifD = "0"; } else { strDiffFifD = e.CellValue.ToString(); } if (double.Parse(strDiffFifD) > 0) { e.Appearance.BackColor = Color.Red; } } } } #endregion