How to get “last saved by” Office file attribute i

2019-07-04 23:58发布

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?

2条回答
劳资没心,怎么记你
2楼-- · 2019-07-05 00:23

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

查看更多
Fickle 薄情
3楼-- · 2019-07-05 00:32

This should work (not tested) :

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

See : POI API docs

查看更多
登录 后发表回答