Spreadsheet wont save to file

I"m following examples and trying to save the spreadsheet to file. as per the following

            FileOutputStream fos = null; 
            Workbook wBook = spreadsheet.getWorkbook();
            fos = new FileOutputStream(new File("CreateExcelDemo.xls")); 
            wBook.write(fos);
            fos.close();

But recieve the following error anyone else experienced this ?

write cannot write data, document seems to have been closed already

I haven’t tried it, but I’m thinking it could be that you’re trying to write to the same file you opened, which won’t work directly like that. You could either try writing to a different file or opening the spreadsheet from a stream instead of a file.

-Olli

Hi thanks for the reply, the spreadsheet is opened from and stream and trying to saved to a new file

HI Just again to make sure the file wasn’t in use. I used the createTemp method and still receive the same error

            File temp = File.createTempFile("CreateExcelDemo", "xls");
            FileOutputStream fos = null; 
            Workbook wBook = spreadsheet.getWorkbook();
            fos = new FileOutputStream(temp); 
            wBook.write(fos);

Hi Still checking for updates, I’ve change the application to now use the write to filename method

The Spreadsheet write method as : https://demo.vaadin.com/javadoc/com.vaadin.addon/vaadin-spreadsheet/1.0.0/com/vaadin/addon/spreadsheet/Spreadsheet.html#write(java.lang.String)

This still fails when suppliing a new filename to write too.