簡體   English   中英

如何在Java中獲取“上次保存”Office文件屬性

[英]How to get “last saved by” Office file attribute in Java

我試圖從MS Office 2013文件(docx,xl​​sx,pptx ...)獲取“最后保存的”屬性。 我正在使用Apache POI,但我只能使用以下代碼獲取文件的作者:

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

有沒有辦法獲得“最后保存”屬性?

看看Apache POI OOXML Properties Extractor是這類問題的一個很好的靈感來源,我們看到你需要做的是

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();

這將為您提供上次修改文件的時間,創建時間和創建時間

這應該工作(未測試):

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

請參閱: POI API文檔

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM