Bladeren bron

More helpful error messages when you try to give POIFS an OOXML file

git-svn-id: https://svn.apache.org/repos/asf/poi/branches/ooxml@681365 13f79535-47bb-0310-9956-ffa450edef68
tags/REL_3_5_BETA2
Nick Burch 16 jaren geleden
bovenliggende
commit
b6af19763e

+ 1
- 1
src/java/org/apache/poi/poifs/storage/HeaderBlockReader.java Bestand weergeven

@@ -105,7 +105,7 @@ public class HeaderBlockReader
_data[1] == OOXML_FILE_HEADER[1] &&
_data[2] == OOXML_FILE_HEADER[2] &&
_data[3] == OOXML_FILE_HEADER[3]) {
throw new OfficeXmlFileException("The supplied data appears to be in the Office 2007+ XML. POI only supports OLE2 Office documents");
throw new OfficeXmlFileException("The supplied data appears to be in the Office 2007+ XML. You are calling the part of POI that deals with OLE2 Office Documents. You need to call a different part of POI to process this data (eg XSSF instead of HSSF)");
}

// Give a generic error

+ 2
- 1
src/testcases/org/apache/poi/poifs/filesystem/TestOffice2007XMLException.java Bestand weergeven

@@ -41,7 +41,8 @@ public class TestOffice2007XMLException extends TestCase {
fail("expected exception was not thrown");
} catch(OfficeXmlFileException e) {
// expected during successful test
assertTrue(e.getMessage().indexOf("POI only supports OLE2 Office documents") > 0);
assertTrue(e.getMessage().indexOf("The supplied data appears to be in the Office 2007+ XML") > -1);
assertTrue(e.getMessage().indexOf("You are calling the part of POI that deals with OLE2 Office Documents") > -1);
}
}

Laden…
Annuleren
Opslaan