poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Anthony Andrews <pythonadd...@yahoo.com>
Subject Re: adding a row to excel file
Date Wed, 31 Oct 2007 17:11:30 GMT
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 <dipen.ml@gmail.com> 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 
Mime
  • Unnamed multipart/alternative (inline, 8-Bit, 0 bytes)
View raw message