1

The below code snippets works perfectly fine when when MSIP_Label_6e9f6ef8-0c49-4ecd-9398-6ef8b9899224_Name is Internal and Private but fails for Confidential and Secret.

XWPFDocument xdoc = new XWPFDocument(OPCPackage.open(fis));
POIXMLProperties props = document.getProperties();
CTProperties customProps = props.getCustomProperties().getUnderlyingProperties();

Gets the below error message when I am trying to read the Custom Properties where I set the property to

MSIP_Label_a7f2ec83-e677-438d-afb7-4c7c0dbc872b_Name: Secret
MSIP_Label_a7f2ec83-e677-438d-afb7-4c7c0dbc872b_Application: Microsoft Azure Information Protection
MSIP_Label_a7f2ec83-e677-438d-afb7-4c7c0dbc872b_Extended_MSFT_Method: Manual
Sensitivity: Secret

org.apache.poi.openxml4j.exceptions.OLE2NotOfficeXmlFileException: The supplied data appears to be in the OLE2 Format. You are calling the part of POI that deals with OOXML (Office Open XML) Documents. You need to call a different part of POI to process this data (eg HSSF instead of XSSF)
    at org.apache.poi.openxml4j.opc.internal.ZipHelper.verifyZipHeader(ZipHelper.java:147)
    at org.apache.poi.openxml4j.opc.internal.ZipHelper.openZipStream(ZipHelper.java:175)
    at org.apache.poi.openxml4j.opc.ZipPackage.<init>(ZipPackage.java:104)
    at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:312)
    at com.akademiskahus.office.utils.ReadDOCXHeaderFooter.getMSWordDocument(ReadDOCXHeaderFooter.java:31)
    at com.akademiskahus.office.utils.ReadDOCXHeaderFooter.main(ReadDOCXHeaderFooter.java:19)
Dharpa
  • 21
  • 1
  • Seems the Word document is encrypted too. Try to decrypt as shown in https://stackoverflow.com/questions/50928926/how-to-open-password-protected-docx-file-in-java/50931931#50931931. – Axel Richter Nov 04 '21 at 11:15

0 Answers0