int cnt = 0;
for (int i = 0; i < sh.length; i++) {
if(sh[i] instanceof OLEShape){
cnt++;
OLEShape ole = (OLEShape)sh[i];
ObjectData data = ole.getObjectData();
if("Worksheet".equals(ole.getInstanceName())){
//Voila! we created a workbook from the embedded OLE data
HSSFWorkbook wb = new HSSFWorkbook(data.getData());
HSSFSheet sheet = wb.getSheetAt(0);
//verify we can access the xls data
assertEquals(1, sheet.getRow(0).getCell((short)0).getNumericCellValue(), 0);
assertEquals(1, sheet.getRow(1).getCell((short)0).getNumericCellValue(), 0);
assertEquals(2, sheet.getRow(2).getCell((short)0).getNumericCellValue(), 0);
assertEquals(3, sheet.getRow(3).getCell((short)0).getNumericCellValue(), 0);
assertEquals(8, sheet.getRow(5).getCell((short)0).getNumericCellValue(), 0);
} else if ("Document".equals(ole.getInstanceName())){
//creating a HWPF document
HWPFDocument doc = new HWPFDocument(data.getData());
String txt = doc.getRange().getParagraph(0).text();
assertEquals("OLE embedding is thoroughly unremarkable.\r", txt);
}
}