title: How to export embeded file which from excel using POI?
body: <p>I have made a java basic program written below, which is making 3 kind of files (ppt,doc,txt) embedded in Excel sheet using Apache POI. Now this file I want to Export with its original format. How to do this?</p>
  
  <p>Reference link is <a href="https://stackoverflow.com/questions/16910503/embed-files-into-excel-using-apache-poi">Embed files into Excel using Apache POI</a>.
  I have made program from this link.</p>
  
  <p>In short I want export functionality on Embedded file.</p>
  
  <p>I have tried above problem using give below code but it not working for exporting embedded file in excel sheet:</p>
  
  <p>Here this is the code which is tried  to solve:</p>
  
  <pre><code>public static void main(String[] args) throws IOException {
      String fileName = "ole_ppt_in_xls.xls";
      ReadExcel(fileName);
  }
  
   public static void ReadExcel(String fileName) throws IOException {
      FileInputStream inputFileStream = new FileInputStream(fileName);
  
      POIFSFileSystem fs = new POIFSFileSystem(inputFileStream);
      HSSFWorkbook workbook = new HSSFWorkbook(fs);
  
      for (HSSFObjectData obj : workbook.getAllEmbeddedObjects()) {
          // the OLE2 Class Name of the object
          String oleName = obj.getOLE2ClassName();
          System.out.println(oleName);
          if (oleName.equals("Worksheet")) {
              System.out.println("Worksheet");
              DirectoryNode dn = (DirectoryNode) obj.getDirectory();
              HSSFWorkbook embeddedWorkbook = new HSSFWorkbook(dn, fs, false);
  
          } else if (oleName.equals("Document")) {
              System.out.println("Document");
              DirectoryNode dn = (DirectoryNode) obj.getDirectory();
              HWPFDocument embeddedWordDocument = new HWPFDocument(dn, fs);
          } else if (oleName.equals("Presentation")) {
              System.out.println("Presentation");
              DirectoryNode dn = (DirectoryNode) obj.getDirectory();
              SlideShow embeddedPowerPointDocument = new SlideShow(
                      new HSLFSlideShow(dn, fs));
          } else if (oleName.equals("Presentation")) {
              System.out.println("Presentation");
              DirectoryNode dn = (DirectoryNode) obj.getDirectory();
              SlideShow embeddedPowerPointDocument = new SlideShow(
                      new HSLFSlideShow(dn, fs));
          }else {
              System.out.println("Else part ");
              if (obj.hasDirectoryEntry()) {
                  System.out.println("obj.hasDirectoryEntry()"+obj.hasDirectoryEntry());
                  // The DirectoryEntry is a DocumentNode. Examine its entries
  
                  DirectoryNode dn = (DirectoryNode) obj.getDirectory();
                  for (Iterator entries = dn.getEntries(); entries.hasNext();) {
                      Entry entry = (Entry) entries.next();
                      System.out.println(oleName + "." + entry.getName());
                  }
              } else {
                  System.out.println("Else part 22");
                  byte[] objectData = obj.getObjectData();
              }
          }
      }
  
  }
  </code></pre>
  
  <p>Output screen of above program:<a href="https://i.stack.imgur.com/tAoGG.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tAoGG.jpg" alt="enter image description here"></a></p>
  
  <p>So ,how to exporting functionality implement? </p>