有轉載有原創,就算做個整理吧.
1、row 的背景顏色交替變換
選中table ->details 然后在
onPrepare方法中加入下面代碼
var count=1;
在onCreate方法中加入下面代碼
count++;
this.getStyle().backgroundColor=(count%2==0?"red":"blue");
這樣表格就可以是紅藍交替顯示了。
2、按一定的條件顯示特定行,比如以紅色顯示數量小于0的行
if( row["inQ"]<0)
this.getStyle().backgroundColor="red";
其中之一"inQ"是表中的列名,不一定是數據集成的列名,一開始以為是數據集成的列名,搞了好長時間。如果列名與數據集中的列名一樣就沒有問題了。
3、參數類型
birt 報表中的日期(date)型參數是java.sql.Date而不是java.util.Date
是看birt 源碼才知道,下面是檢查參數類型的方法的代碼
private boolean validateParameterValueType(String paramName, Object paramValue, String type, ScalarParameterHandle paramHandle)
throws ParameterValidationException
{
if("decimal".equals(type) || "float".equals(type))
if(paramValue instanceof Number)
return true;
else
throw new ParameterValidationException("Error.InvalidParameterType", new String[] {
paramName, type, paramValue.getClass().getName()
});
if("dateTime".equals(type))
if(paramValue instanceof Date)
return true;
else
throw new ParameterValidationException("Error.InvalidParameterType", new String[] {
paramName, type, paramValue.getClass().getName()
});
if("date".equals(type))
if(paramValue instanceof java.sql.Date)
return true;
else
throw new ParameterValidationException("Error.InvalidParameterType", new String[] {
paramName, type, paramValue.getClass().getName()
});
if("time".equals(type))
if(paramValue instanceof Time)
return true;
else
throw new ParameterValidationException("Error.InvalidParameterType", new String[] {
paramName, type, paramValue.getClass().getName()
});
if("string".equals(type))
{
if(paramHandle.isRequired())
{
String value = paramValue.toString().trim();
if(value.length() == 0)
throw new ParameterValidationException("Error.ParameterValueBlank", new String[] {
paramName
});
}
return true;
}
if("boolean".equals(type))
{
if(paramValue instanceof Boolean)
return true;
else
throw new ParameterValidationException("Error.InvalidParameterType", new String[] {
paramName, type, paramValue.getClass().getName()
});
} else
{
return true;
}
}
Technorati : birt
posted on 2008-05-16 16:14
Libo 閱讀(474)
評論(1) 編輯 收藏