You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Tomer Levy <To...@metalink.co.il> on 2003/06/23 13:39:57 UTC

Problem re-writing Files Which Were Manually Edited

Hi,
I created a new xls file and added a short string to one of the cells manually (with Excel application). Now, I want to add new rows to this xls automatically. Adding the new rows works with no exceptions but when I try to open the file manually I get the following error: "File Error. Some number formats may have been lost". What did I do wrong?? 

B.T.W - when I open a NEW xls and write to them using the HSSF these error do not occur.

This is a sample of my code:
FileInputStream input; 
fs  = new POIFSFileSystem(input = new FileInputStream(fileName));
wb = new HSSFWorkbook(fs);
sheet = wb.getSheet(sheetName);
wbName = new String(fileName);

 row = sheet.getRow((short)rowNum);
 HSSFCell cell = row.getCell((short)col);
 if (cell == null)
          cell = row.createCell((short)col);
 cell.setCellType(HSSFCell.CELL_TYPE_STRING);
 cell.setCellValue(str);
//Close 
 FileOutputStream fileOut = new FileOutputStream(wbName);
            wb.write(fileOut);
            fileOut.close();