https://issues.apache.org/bugzilla/show_bug.cgi?id=47543
--- Comment #13 from Yegor Kozlov <[email protected]> 2009-07-31 12:11:06 PST --- Quite an interesting bug. Here is the problem in a nutshell: For reach text containing N runs Excel saves font the first run in the cell style and subsequent N-1 runs override the font in the cell style. Compare two snippets that produce equivalent output: 1. POI approach: HSSFCell hssfCell = row.createCell(idx); //rich text consists of two runs HSSFRichTextString richString = new HSSFRichTextString( "Bug 47543" ); richString.applyFont( 0, 4, font1 ); richString.applyFont( 4, 8, font2 ); hssfCell.setCellValue( richString ); 2. Excel approach //create a cell style and assign the first font to it HSSFCellStyle style = workbook.createCellStyle(); style.setFont(font1); HSSFCell hssfCell = row.createCell(idx); hssfCell.setCellStyle(style); //rich text consists of one run overriding the cell style HSSFRichTextString richString = new HSSFRichTextString( cellValue ); richString.applyFont( 4, 8, font2 ); hssfCell.setCellValue( richString ); It turns out that the way you create HSSFRichTextString cells is important, (1) results in Excel crash while (2) always seems to work. See Driver2 - a version of the attached Driver program that produces valid output readable and modifiable by Excel 2003. driver2-10000.xls is a sample output of 100x100 grid. Regards, Yegor -- 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: [email protected] For additional commands, e-mail: [email protected]
