tags:

views:

24

answers:

1

I have this Java program that uses apache poi to load data from an excel file.

Problem I'm facing is I can't seem to load data from the excel file that is constantly updating. I only get the initial data when I run my java program.

+1  A: 

You have to reread the data from the excel file. POI makes a copy into java objects when it reads it, so any further changes won't get reflected in your Java code without rereading the file.

If you mean that you do reread the file but don't see the updates, then it could be that someone is making changes in excel but not saving them, so POI can't see them yet.

Yishai
so the excel file has to be saved everytime an update is made to it and then my java program can read it?
vamsi
@vamsi, yes, POI can only read a file written to disk. If you need to communicate with a live excel instance to get data out of it, you will need to communicate directly with it using the windows API and some sort of java com bridge such as JACOB.
Yishai
can java (input/output)streams read files in real-time( files being updated, but not saved, to memory) in general?
vamsi
@vamsi, no, Java can only read from disk what has been written to disk. If programs are keeping things in memory, they have to expose methods to communicate with them in-memory. Microsoft Office does this, but of course it is Windows specific, and can't be accessed with pure java.
Yishai