I have this HashMap which contains Strings... I'd like to know when in the
HashMap the word TOTAL is present, if it is present it will set the
background color of all the succeeding values under that column in grey... 
For example: 
          TOTAL 2007
Boys - 300
Girls  - 200
B+G - 500

The values (300, 200 & 500) must have a grey background as well as the
column header Total 2007... 

This is how I did it:
String colName = dynamicColumns.get(idx).toString();
boolean totalValues = colName.startsWith("TOTAL");
if(totalValues)
{
HSSFCellStyle totalStyle = wb.createCellStyle();
totalStyle.setFillForegroundColor(HSSFColor.GREY_25_PERCENT.index);
totalStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
totalStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
outputRowValue(rowValues,locale,ind,object,totalStyle,rowInd,colInd);
}

where outputRowValue is:
public void outputRowValue(Object value, Locale locale, int ind, Object
param, HSSFCellStyle cellStyle, int rowInd, int colInd) {
if(value!=null)
{       
row = sheet.createRow((short)rowInd);
cell = row.createCell((short)colInd);
cell.setCellValue(value.toString());
cell.setCellStyle(cellStyle);
}
}

The problem is it won't change the background color to grey.. How am I
supposed to do this? Thanks!
--

My next question/problem is how will I be able to get the last row generated
in excel? I mean, since I have generated the rows using POI, is there a way
to know on which row the report ended? So I can append other information
below the last row.
-- 
View this message in context: 
http://www.nabble.com/2-Questions-tf3664745.html#a10239740
Sent from the POI - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/

Reply via email to