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
This commit is contained in:
parent
647537c626
commit
155d2b939e
@ -105,7 +105,7 @@ public class HeaderBlockReader
|
|||||||
_data[1] == OOXML_FILE_HEADER[1] &&
|
_data[1] == OOXML_FILE_HEADER[1] &&
|
||||||
_data[2] == OOXML_FILE_HEADER[2] &&
|
_data[2] == OOXML_FILE_HEADER[2] &&
|
||||||
_data[3] == OOXML_FILE_HEADER[3]) {
|
_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
|
// Give a generic error
|
||||||
|
@ -41,7 +41,8 @@ public class TestOffice2007XMLException extends TestCase {
|
|||||||
fail("expected exception was not thrown");
|
fail("expected exception was not thrown");
|
||||||
} catch(OfficeXmlFileException e) {
|
} catch(OfficeXmlFileException e) {
|
||||||
// expected during successful test
|
// 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user