Hi all,

I use POI 3.7 to create Excel files. However, when I decide to set the
background of the Excel file with following code:
FileInputStream ins = new FileInputStream(new
File("/driver/dir/myfile.xls"));
 Workbook wb = new HSSFWorkbook(ins);
 for(int i=0; i< wb.getNumberOfSheets();i++){
        Sheet sheet = wb.getSheetAt(i);
        if(sheet!=null){
           Row row = sheet.getRow(0);
           Iterator<Cell> ct = row.iterator();
           while(ct.hasNext()){
                Cell cell = (Cell) ct.next();
                if(cell!=null){
               HSSFCellStyle hssfstyle = (HSSFCellStyle)
cell.getCellStyle();
                 hssfstyle.setFillBackgroundColor(HSSFColor.YELLOW.index);
                 hssfstyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
                 cell.setStyle(hssfstyle);
                }
          }
        }
}

Thanks
-Zongquan Liu


-----Original Message-----
From: Thomas Sommer [mailto:[email protected]] 
Sent: Tuesday, February 14, 2012 6:24 AM
To: POI Users List
Subject: Re: Read-only access to workbook with protected structure and
window

I did it.

With POI 3.8 beta 5 it's possible to open protected xls-file for reading

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to