2

I know there are several questions asked around this, but no Java solution. My question is same:

My goal is to display the date of an Excel file. But if I download the file from the internet, automatically the creation date and modify date are set to current time and date. I looked upon the file's properties, and found that in section 'Details' , under personal information , there is a section called 'Source' and there , it has a property called 'Content Created' with the original date file.

So, I don't want :- Not this

but this :-

enter image description here

Dave Ranjan
  • 2,966
  • 24
  • 55

1 Answers1

5

POI does support the xls format, though the method for extracting the properties is different from xlsx.

HSSFWorkbook wb = (HSSFWorkbook)WorkbookFactory.create(new File("sample.xls"));             
SummaryInformation props = wb.getSummaryInformation();
System.out.println("Content Created: " + props.getCreateDateTime());

Output:

Content Created: Tue Nov 22 07:49:38 PST 2005

Here's a screenshot of the sample.xls properties that confirms that the required date is being extracted.

enter image description here

RaffleBuffle
  • 5,396
  • 1
  • 9
  • 16