// TODO: exception when no worksheet present
// TODO: make worksheet number configurable/import all worksheets?
public DmnModelInstance convert(InputStream inputStream) {
    SpreadsheetMLPackage spreadSheetPackage = null;
    try {
      spreadSheetPackage = SpreadsheetMLPackage.load(inputStream);
    } catch (Docx4JException e) {
      // TODO: checked exception
      throw new RuntimeException("cannot load document", e);
    }
    WorkbookPart workbookPart = spreadSheetPackage.getWorkbookPart();
    // TODO: exception when no worksheet present
    // TODO: make worksheet number configurable/import all worksheets?
    XlsxWorksheetContext worksheetContext = null;
    WorksheetPart worksheetPart;
    try {
      String worksheetName;
      DocPropsExtendedPart docPropsExtendedPart = spreadSheetPackage.getDocPropsExtendedPart();
      if(docPropsExtendedPart!= null && docPropsExtendedPart.getContents().getTitlesOfParts() != null) {
        worksheetName = (String) docPropsExtendedPart.getContents().getTitlesOfParts().getVector().getVariantOrI1OrI2().get(0).getValue();
      } else {
        worksheetName = "default";
      }
      worksheetPart = workbookPart.getWorksheet(0);
      SharedStrings sharedStrings = workbookPart.getSharedStrings();
      worksheetContext = new XlsxWorksheetContext(sharedStrings.getContents(), worksheetPart.getContents(), worksheetName);
    } catch (Exception e) {
      throw new RuntimeException("Could not determine worksheet", e);
    }
    return new XlsxWorksheetConverter(worksheetContext, ioDetectionStrategy).convert();
  }
}
WorkbookPart workbookPart = spreadSheetPackage.getWorkbookPart();
// TODO: exception when no worksheet present
// TODO: make worksheet number configurable/import all worksheets?
XlsxWorksheetContext worksheetContext = null;
WorksheetPart worksheetPart;
public DmnModelInstance convert(InputStream inputStream) {
SpreadsheetMLPackage spreadSheetPackage = null;
try {
spreadSheetPackage = SpreadsheetMLPackage.load(inputStream);
} catch (Docx4JException e) {
// TODO: checked exception
throw new RuntimeException("cannot load document", e);
}
WorkbookPart workbookPart = spreadSheetPackage.getWorkbookPart();
// TODO: exception when no worksheet present
// TODO: make worksheet number configurable/import all worksheets?
XlsxWorksheetContext worksheetContext = null;
WorksheetPart worksheetPart;
try {
String worksheetName;
DocPropsExtendedPart docPropsExtendedPart = spreadSheetPackage.getDocPropsExtendedPart();
if(docPropsExtendedPart!= null && docPropsExtendedPart.getContents().getTitlesOfParts() != null) {
worksheetName = (String) docPropsExtendedPart.getContents().getTitlesOfParts().getVector().getVariantOrI1OrI2().get(0).getValue();
} else {
worksheetName = "default";
}
public DmnModelInstance convert(InputStream inputStream) {
SpreadsheetMLPackage spreadSheetPackage = null;
try {
spreadSheetPackage = SpreadsheetMLPackage.load(inputStream);
} catch (Docx4JException e) {
// TODO: checked exception
throw new RuntimeException("cannot load document", e);
}
WorkbookPart workbookPart = spreadSheetPackage.getWorkbookPart();
// TODO: exception when no worksheet present
// TODO: make worksheet number configurable/import all worksheets?
XlsxWorksheetContext worksheetContext = null;
WorksheetPart worksheetPart;
try {
String worksheetName;
DocPropsExtendedPart docPropsExtendedPart = spreadSheetPackage.getDocPropsExtendedPart();
if(docPropsExtendedPart!= null && docPropsExtendedPart.getContents().getTitlesOfParts() != null) {
worksheetName = (String) docPropsExtendedPart.getContents().getTitlesOfParts().getVector().getVariantOrI1OrI2().get(0).getValue();
} else {
worksheetName = "default";
}
worksheetPart = workbookPart.getWorksheet(0);
SharedStrings sharedStrings = workbookPart.getSharedStrings();
worksheetContext = new XlsxWorksheetContext(sharedStrings.getContents(), worksheetPart.getContents(), worksheetName);
} catch (Exception e) {
throw new RuntimeException("Could not determine worksheet", e);
}
return new XlsxWorksheetConverter(worksheetContext, ioDetectionStrategy).convert();
}