Nick93
(Nick Barnes)
May 10, 2017, 12:56pm
1
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
ollit.1
(Olli Tietäväinen)
May 11, 2017, 8:30am
2
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
Nick93
(Nick Barnes)
May 11, 2017, 8:53am
3
Hi thanks for the reply, the spreadsheet is opened from and stream and trying to saved to a new file
Nick93
(Nick Barnes)
May 15, 2017, 10:01am
4
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);
Nick93
(Nick Barnes)
May 31, 2017, 6:35am
5
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.