You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Enrique Zudaire <zu...@mail.nih.gov> on 2011/02/11 22:29:15 UTC

Appending data to an opened Excel File

Hi all

I'm using POI to write Excel files from a java program. Everything works well. 
I was just wondering if it is possible to dynamically append data to a file wile
the file is opened with Excel. I'd like to do that to let the user visualize the
new data as the data is appended to the file. 

Thank you in advance for your help
Kike



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: Appending data to an opened Excel File

Posted by David Fisher <df...@jmlafferty.com>.
> I'm using POI to write Excel files from a java program. Everything works well. 
> I was just wondering if it is possible to dynamically append data to a file wile
> the file is opened with Excel. I'd like to do that to let the user visualize the
> new data as the data is appended to the file. 

This is not exactly easy. Think of it this way both Excel and a JVM with your POI Application will both try to have the same file open at the same time and you want to write with one process.

The only way you might be able to do this is as follows. This is theoretical though it may not work and error checking will be needed.

(1) You have a special VBA Macro or Visual Studio Add-in that re-opens your file over and over. Or the user could do this manually.

(2) Your Java / POI application will need to perform the following every time you want to dynamically add data.

- Open a copy of the workbook.
- Append the data.
- Write the whole workbook.
- Close the copy the workbook.
- Move the copy over the original. This could fail if Excel still has a handle on the file.

Not very efficient but there is some hope that this might work.

Regards,
Dave
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org