...............and I should have said that yes, you can use HSSF/XSSF to
create a copy of the file. There is a method called write() defined on the
HSSFWorkbook class that could be used to create a copy of the file if you
are dealing with a binary .xls file. Further, there is a writeFileSystem()
method defined on the POIFSFileSystem class that you might be able to use to
create a copy of the file though I have never tried this myself. You would
simply pass an output stream to either and save the file you have opened
away under a new name and/or to a different location.

My only concern is that calling one of the write methods will also close the
streams for you and that this could cause problems if you wished to process
the original file after creating the copy. Having said this, I do not know
whether this is the case.


AlyssaK wrote:
> 
> Hi everyone,
> 
> I was just wondering if i can use POI to save a copy of the Excel file
> that i am reading on the file system?  I've looked through the API only
> found references to creating new Excel files.  If you have a suggestion
> how i would go about this please post a response. Thanks.
> 
> 
> I am using the following method to open the Excel Spreadsheet:
> 
> public static void parseFileSetup(){
> try{
> // open the Excel Spreadsheet
> POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream(filename));
>                               
> // check if the file was found
> if (fs==null){
>   System.out.println("fs is null");
> }
> wb = new HSSFWorkbook(fs);
> }catch ( IOException ex ) {
>      ex.printStackTrace();
> }
> }
> 
> 
> Eventually users will be uploading files so I need to save it.
> 
> 

-- 
View this message in context: 
http://www.nabble.com/How-to-save-the-Excel-file-to-file-system-tp23363786p23364267.html
Sent from the POI - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to