锐浪 报表, 交叉报表中 对交叉字段,做条件改变背景颜色 .
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;}
posted on 2014-06-17 17:29 阅读( ...) 评论( ...) 收藏