Bug 36947

Summary: HSSF won't correctly copy/modify a sheet containing comments
Product: POI Reporter: Luke Chadwick <lukec>
Component: HSSFAssignee: POI Developers List <dev>
Status: RESOLVED FIXED    
Severity: major    
Priority: P2    
Version: 3.0-dev   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Attachments: XLS file causing the problem

Description Luke Chadwick 2005-10-06 11:02:12 UTC
Reading up on the issue suggested that similar bugs have been reported, once a
given spreadsheet is copied and modified, excel returns an error on opening
about the file being too damaged to open. Experimenting with they issue lead me
to the conclusion it was only doing on certain spreadsheets, while others would
work perfectly, specifically once I deleted the 'comments' from the spreadsheet
in question (i'll attach it) it worked correctly.

public void testModify(String filename)
{
   try 
   {
	in = new FileInputStream("exists.xls");
	fs = new POIFSFileSystem(in);
        HSSFWorkbook     wb     = new HSSFWorkbook(fs);
        FileOutputStream stream = new FileOutputStream("exists-copy.xls");
        HSSFSheet        sheet  = wb.getSheetAt(0);
        HSSFRow  row  = sheet.getRow(5);
        HSSFCell cell = row.getCell(( short ) 5);
        cell.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
        cell.setCellValue(9999);
        wb.write(stream);
        stream.close();
    }
    catch (Exception e)
    {
        e.printStackTrace();
    }
}

Both 2.5.1-final and poi-bin-3.0-alpha1-20050704 appear to have the same problem.
Comment 1 Luke Chadwick 2005-10-06 11:04:48 UTC
Created attachment 16603 [details]
XLS file causing the problem
Comment 2 Yegor Kozlov 2008-05-17 06:01:42 UTC
The problem seems to be fixed in poi-3.1-beta1.

Yegor