0

With POIXMLProperties.getCoreProperties() and POIXMLProperties.getExtendedProperties()

I can set all the metadata values ​​except "Last Modified By", Is there any way to set it?

Thanks for advance.

4

1 回答 1

1

我正在使用 POI 3.10-beta1,它适用于我,即您可以直接在以下位置进行设置PackageProperties

import java.util.Date;
import org.apache.poi.openxml4j.opc.*;
import org.apache.poi.openxml4j.util.Nullable;

public class LastModifiedBy {
    public static void main(String[] args) throws Exception {
        OPCPackage opc = OPCPackage.open("lastmodifed.docx");
        PackageProperties pp = opc.getPackageProperties();
        Nullable<String> foo = pp.getLastModifiedByProperty();
        System.out.println(foo.hasValue()?foo.getValue():"empty");
        pp.setLastModifiedByProperty("user"+System.currentTimeMillis());
        pp.setModifiedProperty(new Nullable<Date>(new Date()));
        opc.close();
    }
}
于 2013-08-31T17:39:36.813 回答