我使用下面的代码在邮件正文中创建了 html 表
st = con.createStatement();
rs = st.executeQuery("SELECT nvl(tt.ACTIVITY_NAME,'') as ACTIVITY_NAME, "
+ " nvl(tt.TL_NAME,'') TL_NAME, "
+ " nvl(tt.UW_NAME,'') UW_NAME, "
+ " nvl(tt.TAT_1,'') TAT_1,"
+ " nvl(tt.TAT_2,'') TAT_2, "
+ " nvl(tt.TAT_3,'') TAT_3, "
+ " nvl(tt.TAT_4,'') TAT_4, "
+ " nvl(tt.TAT_4_PLUS ,'') TAT_4_PLUS, "
+ " nvl(tt.g_total ,'') AS GRAND_TOTAL "
+ " FROM uw_activity_tl_uw_tat tt "
+ " WHERE tt.ACTIVITY_NAME = 'First UW' "
+ " ORDER BY tt.TL_NAME,tt.UW_NAME");
StringBuffer sb = new StringBuffer();
ResultSetMetaData rsmd = rs.getMetaData();
int numColumns = rsmd.getColumnCount();
for (int i = 1; i < numColumns + 1; i++) {
String columnName = rsmd.getColumnName(i);
sb.append("<th bgcolor=#fcbe07>" + columnName + "</th>");
}
ArrayList<String> a = new ArrayList<String>();
while (rs.next()) {
a.add(rs.getString(3));
if (rs.getRow() % 2 == 0) {
sb.append("<tr bgcolor=#fcf6cf>");
for (int i = 1; i < numColumns + 1; i++) {
if (rs.getString(i) == null) {
if(i==3)
{
sb.append("<td bgcolor=#fcbe07><b>"+ " "+ "</b></td>");
}
} else {
if (i == 6 || i == 7 || i == 8)
sb.append("<td><FONT COLOR=#ff0000>"
+ rs.getString(i) + "</FONT></td>");
else if(i==3 && (rs.getString(3).equalsIgnoreCase("") || rs.getString(3)==null)){
sb.append("<td bgcolor=#fcbe07><b>"+ rs.getString(i) + "</b></td>");
}else{
sb.append("<td>" + rs.getString(i) + "</td>");
}
}
}
sb.append("</tr>");
} else {
sb.append("<tr>");
for (int i = 1; i < numColumns + 1; i++) {
if (rs.getString(i) == null) {
if(i==3)
{
sb.append("<td bgcolor=#fcbe07><b>"+ " " + "</b></td>");
}
} else {
if (i == 6 || i == 7 || i == 8)
sb.append("<td><FONT COLOR=#ff0000>"
+ rs.getString(i) + "</FONT></td>");
else if(i==3 && (rs.getString(3).equalsIgnoreCase("") || rs.getString(3)==null)){
sb.append("<td bgcolor=#fcbe07><b>"+ rs.getString(i) + "</b></td>");
}else{
sb.append("<td>" + rs.getString(i) + "</td>");
}
}
}
sb.append("</tr>");
}
}
String html = "<html>" + message.getSubject()
+ "</title></head><body><table border=\"1\">"
+ sb.toString() + "</table></body></html>";
message.setContent(html, "text/html");
在图像中,只有一个单元格被突出显示,我想突出显示包含任何空单元格的整行。请指导。我的查询是如果任何单元格为空,如何突出显示整行。