I feel dumb asking this, but right now I'm using Apache POI to write to an Excel document. But as of right now, every time I run the program it doesn't save the data to the excel document, meaning the next time I run it the data from previous trails isn't there. Is there a line of code for saving all the info gathered during a trial so that it is still there in future trials?
-
Sorry I wasnt very clear, I guess what I mean is when I run the program and gather information from the user. I want it to permanently save the data to the excel document. As of now it will create the excel document but once I run the program again, the data from the previous run is no longer stored. I want to be able to keep the data from each successive run.JBurk94– JBurk942014-03-30 21:33:37 +00:00Commented Mar 30, 2014 at 21:33
4 Answers
Assuming you're trying to save the created workbook to the file system, I think you want Workbook.write and one of the constructors for the spreadsheet format you use to read it in again (e.g. XSSFWorkbook(java.io.InputStream from here)
write
void write(java.io.OutputStream stream) java.io.IOException
Write out this workbook to an Outputstream.
Parameters:
stream - - the java OutputStream you> wish to write to
Throws: java.io.IOException - if anything can't> be written.
Comments
There is an example on the JED website you might want to check out which demonstrates how to collect data from an HTML table and save it to an Excel file using the POI library. You should get all you need in the way of servlet code to replicate for your purposes.
Try: http://jed-datatables.ca/jed/examples/exporttoexcel2.html