https://issues.apache.org/bugzilla/show_bug.cgi?id=48877
Graham Smith <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |REOPENED Resolution|WORKSFORME | --- Comment #5 from Graham Smith <[email protected]> 2011-04-20 07:07:36 EDT --- I've just run into this issue in 3.7 so I upgraded to 3.8-beta2 and I'm still experiencing what seems to be strange behaviour. The code below shows the problem which I think might be related to the line-break "\n" being treated as two characters. For example, on row zero it's impossible to completely style the word "Incorrect" and also end up with a line break. I would have expected "Incorrect" to be fully styled when i == 2 then a line-break and then the text "Line-Breaking" what actually happens is "Incorrect" is styled, the line-break is removed or ignored and "Line-Breaking" is placed hard up against "Incorrect". Interestingly when i == 4 so that the first character of "Line-Breaking" is styled the line-break re-appears. I've worked around this issue by putting spaces around the line-break character which lets me style each part individually at the cost of some extra space but that's not so noticeable when the text is centred. XSSFCellStyle headerStyle = (XSSFCellStyle) wb.createCellStyle(); headerStyle.setWrapText(true); Font largeHeaderfont = wb.createFont(); largeHeaderfont.setBoldweight(Font.BOLDWEIGHT_BOLD); largeHeaderfont.setFontHeightInPoints((short) 14); CreationHelper createHelper = wb.getCreationHelper(); Row row0 = sheet.createRow(0); for( int i = 0, n = 7; i < n; i++ ) { RichTextString headerString = createHelper.createRichTextString("Incorrect\nLine-Breaking"); headerString.applyFont(0, 7 + i, largeHeaderfont); Cell cell = row0.createCell(i); cell.setCellStyle(headerStyle); cell.setCellValue(headerString); } Row row1 = sheet.createRow(1); for( int i = 0, n = 7; i < n; i++ ) { RichTextString headerString = createHelper.createRichTextString("Incorrect \n Line-Breaking"); headerString.applyFont(0, 7 + i, largeHeaderfont); Cell cell = row1.createCell(i); cell.setCellStyle(headerStyle); cell.setCellValue(headerString); } -- 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]
