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

           Summary: corrupt xls file after modifying one column
           Product: POI
           Version: 3.0
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: major
          Priority: P2
         Component: HSSF
        AssignedTo: dev@poi.apache.org
        ReportedBy: [EMAIL PROTECTED]


I am using HSSF to read 14000+ line xls file and save it into a copy, with one
modification: stripping RTF control chars from one column.  When I tried to
open this output xls, I get "Excel found unreadable content in [filename]."  If
I allow Excel (v 2003 SP3) to repair the file, it changes my date and currency
columns to general cell format.

Code:

Iterator rit = sheet.rowIterator();
rit.next();
for(int i = 1; rit.hasNext(); i++) {
  row = (HSSFRow)rit.next();
  HSSFCell commentsCell = row.getCell(commentsIdx);
  if(commentsCell != null) {
    rtfComments = commentsCell.getRichStringCellValue().getString();

    RTFEditorKit kit = new RTFEditorKit();
    Document doc = kit.createDefaultDocument();
    kit.read(new StringReader(rtfComments), doc, 0);
    txtComments = doc.getText(0, doc.getLength());

    commentsCell.setCellValue(new HSSFRichTextString(txtComments));
  }
}

// write converted workbook to file
FileOutputStream fileOut = new FileOutputStream(outfile);
wb.write(fileOut);
fileOut.close();


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