https://issues.apache.org/bugzilla/show_bug.cgi?id=50258

           Summary: XSSFRichTextString corrupts Excel file when
                    applyFont() is used
           Product: POI
           Version: 3.7
          Platform: PC
            Status: NEW
          Severity: major
          Priority: P2
         Component: XSSF
        AssignedTo: [email protected]
        ReportedBy: [email protected]


Created an attachment (id=26284)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=26284)
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"));
  }
}

-- 
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]

Reply via email to