Are you saying that after you insert the 'new' value into the cell the 
formatting that had previously been applied to that cell is lost?

If so, then you need to read the existing formatting from the cell and store it 
into a local variable, change the cell's value and then re-apply the formatting 
that you read.

Dipen Javia <[EMAIL PROTECTED]> wrote: I have a following code where I am 
trying to add a value to an existing
sheet. But for some reason, it works on some cells and it doesnt for others.
I think its a format issue how do i know the format of the cell and figure
out the format setting?

try {
        String filename = "C:/m/util.xls";
        POIFSFileSystem fs  = new POIFSFileSystem(new
FileInputStream(filename));
        HSSFWorkbook wb = new HSSFWorkbook(fs);
        HSSFSheet sheet = wb.getSheetAt((short)0);
        int i = 17;
        HSSFRow row = sheet.getRow(i);
        HSSFCell cell = row.getCell((short) 1);
        cell.setCellValue("test!");
        FileOutputStream fileOut = new FileOutputStream(filename);
        fileOut = new FileOutputStream(filename);
        wb.write(fileOut);
        fileOut.close();
        }catch(Exception e) { e.printStackTrace(); }

some of the cells have same formatting but still it works on some cells and
it doesnt on others.


 __________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Reply via email to