Skip to content

Commit

Permalink
Merge pull request #149 from ochedru/ability_to_read_xlsm
Browse files Browse the repository at this point in the history
Ability to read Excel xlsm files
  • Loading branch information
Olivier Chédru authored Feb 10, 2021
2 parents 0ae2c35 + e157212 commit e569400
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,12 @@ private PartEntryNames extractPartEntriesFromContentTypes() throws XMLStreamExce
final String contentTypesXml = "[Content_Types].xml";
try (SimpleXmlReader reader = new SimpleXmlReader(factory, getRequiredEntryContent(contentTypesXml))) {
while (reader.goTo(() -> reader.isStartElement("Override"))) {
if (PartEntryNames.WORKBOOK_MAIN_CONTENT_TYPE.equals(reader.getAttributeRequired("ContentType"))) {
String contentType = reader.getAttributeRequired("ContentType");
if (PartEntryNames.WORKBOOK_MAIN_CONTENT_TYPE.equals(contentType)
|| PartEntryNames.WORKBOOK_EXCEL_MACRO_ENABLED_MAIN_CONTENT_TYPE.equals(contentType)) {
entries.workbook = reader.getAttributeRequired("PartName");
}
if (PartEntryNames.SHARED_STRINGS_CONTENT_TYPE.equals(reader.getAttributeRequired("ContentType"))) {
if (PartEntryNames.SHARED_STRINGS_CONTENT_TYPE.equals(contentType)) {
entries.sharedStrings = reader.getAttributeRequired("PartName");
}
if (entries.isFullyFilled()) {
Expand Down Expand Up @@ -128,7 +130,9 @@ public InputStream getSheetContent(Sheet sheet) throws IOException {

private static class PartEntryNames {
public static final String WORKBOOK_MAIN_CONTENT_TYPE =
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml";
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml";
public static final String WORKBOOK_EXCEL_MACRO_ENABLED_MAIN_CONTENT_TYPE =
"application/vnd.ms-excel.sheet.macroEnabled.main+xml";
public static final String SHARED_STRINGS_CONTENT_TYPE =
"application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml";
String workbook;
Expand Down

0 comments on commit e569400

Please sign in to comment.