You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Navin Nair <na...@infosys.com> on 2004/03/05 04:38:25 UTC
POI Query: Retrieving background color information
Hi All,
I am new to POI and I am using it to read an excel sheet which has some rows/columns marked in a particular color. I have some processing to be done based on the style (for eg: color) of the cell. But when I do style.getFillBackgroundColor(), I always get 64 as the value for any color. I have attached the code I am using with this mail.
String filename = "C:/WorkBook.xls";
POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream(filename));
HSSFWorkbook wb = new HSSFWorkbook(fs);
HSSFSheet sheet = wb.getSheetAt(0);
for( int r = 0; r <= sheet.getLastRowNum(); r++ ) {
HSSFRow row = sheet.getRow(r);
System.out.println("Row : " + r);
if( row != null ) {
for( short c = 0; c <= row.getLastCellNum(); c++ ) {
HSSFCell cell = row.getCell(c);
if( cell != null ) {
HSSFCellStyle style = cell.getCellStyle();
System.out.println(style.getFillBackgroundColor() + " " +
style.getFillPattern() + " " + cell.getStringCellValue());
}
}
}
}
I think I am doing something wrong or have missed something. Can somebody please point out what needs to be done to get a background color?.
Regards,
Navin
---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: poi-user-help@jakarta.apache.org