save a excel file with poi

Hi.

i want to save the modification i made in a excel file using poi, without open the MS excel program and do it manually ( Ctrl+s)...

i used

FileOutputStream out = null;

out = new FileOutputStream("c:/VolumeDetails.xls");

wbD.write(out);

but the program not recognize de changes until i saved manualy

and i need to work with these modifications.

i hope you can help me. Thanks!

[434 byte] By [Camposa] at [2007-11-27 10:26:39]
# 1

Off hand, I think you need to flush the output stream and close it. If you dont flush and close, the changes aren't committed.

George123a at 2007-7-28 17:40:43 > top of Java-index,Java Essentials,Java Programming...
# 2

i have try to flush the ouput stream , but it does not work either

Camposa at 2007-7-28 17:40:43 > top of Java-index,Java Essentials,Java Programming...
# 3

HSSFWorkbook workBook = new HSSFWorkbook();

FileOutputStream fileOutputStream = new FileOutputStream("filestreams_workbook.xls");

HSSFSheet sheet = workBook.createSheet();

HSSFRow excelRow = sheet.createRow((short)0);

HSSFCell dataCell = excelRow.createCell((short)0);

dataCell.setCellValue(1);

workBook.write(fileOutputStream);

fileOutputStream.close();

filestreama at 2007-7-28 17:40:43 > top of Java-index,Java Essentials,Java Programming...
# 4

Sorry, I'm out of ideas.

George123a at 2007-7-28 17:40:43 > top of Java-index,Java Essentials,Java Programming...
# 5

FileOutputStream out = null;

out = new FileOutputStream("c:/VolumeDetails.xls");

I can never understand why people do this. Why would you initialize something to null when you change its value on the very next line?

wbD.write(out);

You must have got an IOException somewhere if the above didn't produce a new file. What was it? Or do you have the dreaded empty-catch-block problem?

ejpa at 2007-7-28 17:40:43 > top of Java-index,Java Essentials,Java Programming...