var fieldCount = Report.RunningDetailGrid.ColumnContent.ContentCells.Count; // 总字段列数 var lockFieldCount = Report.DetailGrid.CrossTab.ListCols; // 锁定字段列数 var crossFieldCount = fieldCount - lockFieldCount; for(var colIndex = 1; colIndex <=crossFieldCount;colIndex++) { var crossFieldName = "Amount_" + colIndex; var AmountContentCell = Report.RunningDetailGrid.ColumnContent.ContentCells.Item(crossFieldName); var cellName = AmountContentCell.DataField; var AmountField =Report.RunningDetailGrid.Recordset.Fields.Item(cellName); var FontBold = false; var FontItalic = false; var TextColor; var BackColor; if (AmountField.AsFloat > 450) { FontBold = true; FontItalic = true; TextColor = GetColorValue(0, 255, 0); BackColor = GetColorValue(255, 0, 0); }else{ TextColor = GetColorValue(0, 0, 0); BackColor = GetColorValue(255, 255, 255); } SetContentCellBackColor(AmountContentCell,BackColor); SetContentCellBold(AmountContentCell,FontBold); } /************************ 函数方法 ******************************/ /** * 设置单元格背景颜色 * @author WUYF */ function SetContentCellBackColor(oContentCell,backColor) { oContentCell.BackColor = backColor; } /** * 设置单元格内容粗体 * @author WUYF */ function SetContentCellBold(oContentCell,isBold) { oContentCell.Font.Bold = isBold; } function GetColorValue(r,g,b) { return r + g*256 + b*256*256; }
锐浪 报表, 交叉报表中 对交叉字段,做条件改变背景颜色 .
时间: 2024-10-27 02:00:14