Created attachment 26284 [details] Corrupted Rich Text XLSX Excel complains that the file created by the followin example is corrupted. Two fonts are applied to the string "plain bold italic plain" and the space before "bold" is removed. If you strip of the last five chars (" plain"), the file opens without a warning but the space between "plain" and "bold" is still missing. The errors make the font aplying unusable for XSSF. The same test case with HSSF works fine. ---------- import java.io.FileOutputStream; import org.apache.poi.ss.usermodel.*; import org.apache.poi.xssf.usermodel.XSSFWorkbook; public class PoiRichTextBug { public static void main(String[] args) throws Exception { Workbook workbook = new XSSFWorkbook(); Sheet sheet = workbook.createSheet(); Row row = sheet.createRow(0); Cell cell = row.createCell(0); RichTextString text = workbook.getCreationHelper().createRichTextString("plain bold italic plain"); Font font = workbook.createFont(); font.setBoldweight(Font.BOLDWEIGHT_BOLD); text.applyFont(6, 10, font); font = workbook.createFont(); font.setItalic(true); text.applyFont(11, 17, font); cell.setCellValue(text); workbook.write(new FileOutputStream("RichText.xlsx")); } }
Could you please create the same document using excel? We can then compare the XML generated by POI, and the XML generated by excel, and hopefully spot what POI is doing wrong in your case.
Created attachment 26291 [details] Corrupted file (generated by POI)
Created attachment 26292 [details] Valid file (generated by Excel 2010)
(In reply to comment #1) > Could you please create the same document using excel? We can then compare the > XML generated by POI, and the XML generated by excel, and hopefully spot what > POI is doing wrong in your case. The two new attachments describe the test case. Hope this helps.
Fixed in r1036599 Yegor