0

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.

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

4 Comments

so the excel file has to be saved everytime an update is made to it and then my java program can read it?
@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.
can java (input/output)streams read files in real-time( files being updated, but not saved, to memory) in general?
@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.
0

This Answer is referred from Fetch Data From Excel have a look at this answer for more details. Maybe this question is a duplicate of the above link or vice versa.

The problem is because the excel data is not saved. I was also dealing with the same problem and got up with a different solution which worked for me. I just created a macro in excel to save the excel workbook whenever it's cell values got changed. Now I got the excel file with up-to-date saved data which can be read through java code and can be used for other purposes.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.