You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2010/05/05 17:17:58 UTC
DO NOT REPLY [Bug 49254] New: CellUtil.setFont fails
https://issues.apache.org/bugzilla/show_bug.cgi?id=49254
Summary: CellUtil.setFont fails
Product: POI
Version: 3.6
Platform: PC
OS/Version: Windows XP
Status: NEW
Severity: normal
Priority: P2
Component: XSSF
AssignedTo: dev@poi.apache.org
ReportedBy: thomas.herre@abosco.com
Description:
This bug applies to both XSSF and HSSF:
In a workbook, I create a bold font.
Setting this font to a cell using method CellUtil.setFont fails.
Instead, the font at index 0 is used.
Test Code:
Workbook workbook = new XSSFWorkbook();
Sheet sheet = workbook.createSheet();
Row row = sheet.createRow(0);
Cell cell = row.createCell(0);
cell.setCellValue("TestCell");
Font font = workbook.createFont();
font.setBoldweight(Font.BOLDWEIGHT_BOLD);
font.setFontHeightInPoints((short) 20);
// This fails
CellUtil.setFont(cell, workbook, font);
// Workaround
// short fontIndex = font.getIndex();
// CellUtil.setCellStyleProperty(cell, workbook, CellUtil.FONT,
Short.valueOf(fontIndex));
workbook.write(new FileOutputStream(new File("test-font.xlsx")));
Evaluation:
CellUtil.setFont calls method setCellStyleProperty and passes-in a Font object
as parameter "propertyValue". It fails a find a style that it can reuse and
creates a new one. Then it calls setFormatProperties which in turn looks up the
font using method getShort. Tha map passed-in contains almost only Short object
as values, but a Font object for property "font". Thus it returns the default
value 0.
Workaround:
Avoid method CellUtil.setFont and use the workaround (as commented-out in the
above test code).
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
DO NOT REPLY [Bug 49254] CellUtil.setFont fails
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=49254
Nick Burch <ni...@alfresco.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
--- Comment #1 from Nick Burch <ni...@alfresco.com> 2010-05-05 11:25:38 EDT ---
Should be fixed in r941342.
Note that things in contrib don't always receive the same level of testing as
in the main jar file, as they generally lack unit tests :/
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org