4

I am trying to get the "last saved by" attribute from MS Office 2013 file(docx, xlsx, pptx ...). I am using Apache POI, but I can get only the Author of the file with the following code:

OPCPackage pkg = OPCPackage.open(file);
POIXMLProperties props = new POIXMLProperties(pkg);
props.getCoreProperties().getCreator();

Is there a way to get "last saved by" attribute?

Wolfgang Fahl
  • 15,016
  • 11
  • 93
  • 186
Ivaylo
  • 43
  • 4

2 Answers2

2

Lookin at the Apache POI OOXML Properties Extractor as a good source of inspiration for this sort of problem, we see what you need to do is

OPCPackage pkg = OPCPackage.open(file);
POIXMLProperties props = new POIXMLProperties(pkg);
PackagePropertiesPart ppropsPart = props.getCoreProperties().getUnderlyingProperties();

Date created = ppropsPart.getCreatedProperty().getValue();
Date modified = ppropsPart.getModifiedProperty().getValue();

String lastModifiedBy = ppropsPart.getLastModifiedByProperty().getValue();

That'll give you who last modified the file, when, and when it was created

VincentS
  • 602
  • 1
  • 10
  • 24
Gagravarr
  • 47,320
  • 10
  • 111
  • 156
0

This should work (not tested) :

OPCPackage pkg = OPCPackage.open(file);
pkg.getPackageProperties().getLastModifiedByProperty();

See : POI API docs

jeroen_de_schutter
  • 1,843
  • 1
  • 18
  • 21