I generate a heavy file using Apache POI within 10 minutes. To minimize the memory usage and time, I generate the file only when I detect a change in my record. If not, I will just fetch the old most recent Excel file for download. The problem is how can I get the creation date of the old Excel file? I am thinking of using the Apache's PackageProperties
class although I don't know how to achieve that.
- Get the file via
FileInputStream
. - Read that file via
new XSSFWorkbook(FileInputStream inputStream)
. - I don't know the next step here to connect #2 and #4.
- Next is get the
PackageProperties
attribute of that workbook. - Use the
PackageProperties.getCreatedProperty()
to get the creation date. - If there is a change detected after the creation date of the file, we then start generating the file, then overwrite the old version of the file with the new one, then proceeds to download. If there are no changes detected, proceeds to download the previous file.
Now, how can I get that PackageProperties
attribute of the workbook?
I had checked this other entry with a similar case (but using a CSV rather than Excel), but it seems using the last modified property of the file is not always identical to the creation date.