Bug 50912

Summary: Applying an HSSFCellStyle on an HSSFCell has no effect
Product: POI Reporter: Martin Studer <martin.studer>
Component: HSSFAssignee: POI Developers List <dev>
Status: RESOLVED FIXED    
Severity: normal CC: skiping
Priority: P2    
Version: 3.8-dev   
Target Milestone: ---   
Hardware: PC   
OS: All   
Attachments: Template Excel file with user-defined cellstyle "FatFont"

Description Martin Studer 2011-03-10 16:18:30 UTC
Created attachment 26761 [details]
Template Excel file with user-defined cellstyle "FatFont"

Please see the following snippet of code which detects a user-defined cellstyle in an Excel file and then tries to apply this celstyle on the top left cell in the 'MySheet' worksheet.

HSSFWorkbook wb = new HSSFWorkbook(new FileInputStream("template.xls"));
        for(short i = 0; i < wb.getNumCellStyles(); i++) {
            HSSFCellStyle cs = wb.getCellStyleAt(i);
            String userStyleName = cs.getUserStyleName();
            if(userStyleName != null && userStyleName.equals("FatFont")) {
                System.out.println("Found!");
                wb.getSheet("MySheet").getRow(0).getCell(0).setCellStyle(cs);
                break;
            }
        }

        FileOutputStream fos = new FileOutputStream("template2.xls");
        wb.write(fos);
        fos.close();

When opening template2.xls it can be seen that applying the detected cellstyle actually had no effect.

Please find the file template.xls attached.
Comment 1 Yegor Kozlov 2011-03-11 12:34:17 UTC
Fixed in r1080689

Yegor
Comment 2 Yegor Kozlov 2011-03-11 12:35:25 UTC
*** Bug 50302 has been marked as a duplicate of this bug. ***