Bug 50912 - Applying an HSSFCellStyle on an HSSFCell has no effect
Summary: Applying an HSSFCellStyle on an HSSFCell has no effect
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 3.8-dev
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
: 50302 (view as bug list)
Depends on:
Blocks:
 
Reported: 2011-03-10 16:18 UTC by Martin Studer
Modified: 2011-03-11 12:35 UTC (History)
1 user (show)



Attachments
Template Excel file with user-defined cellstyle "FatFont" (17.50 KB, application/vnd.ms-excel)
2011-03-10 16:18 UTC, Martin Studer
Details

Note You need to log in before you can comment on or make changes to this bug.
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. ***