Read embedded MSWord file from excel uand save it on drive using Java -


I have an Excel file in which two MS Word files have been embedded in it. I am using Apache POI to read an embedded object from an Excel file in Java. The problem occurs when I read the embedded file and save it to disk and opens the saved file in MS Word, MS Word could not read its format. Open with Excel file then opened directly and MS Word read it properly. Anybody helps me [code]

  public class test {public static zero main (string [] args throws exceptions (file file = new file ("C: / Book2 .xls "); NPOIFS Filesystem FS = New NPOFI Filesystem (File); HSSFWorkbook wb = New HSSFWorkbook (fs.getRoot (), for true); (HSSFObjectData obj: wb.getAllEmbeddedObjects ()) {string oleName = obj.getOLE2ClassName () ; DirectoryNode dn = (DirectoryNode) obj.get directory (); Iterator & lt; Entry & gt; Ab = dn.getEntries (); if (olyname contains ("document AZ ")) {HWPF Document embedded Word document = new HPPF document (DN); string docTitle = Embedded document.GetSamuri Information (.) GetTitle (); InputStream; entry entry = ab.next (); is = dn.createDocumentInputStream (Entry); FileOutputStream fos = New FileOutputStream ("d: /" + docTitle + ".doc"); Println (is.available ()); Println (((DocumentEntry) entry) .getSize ()); IOUtils.copy (Is, fos); fos.close (); is close(); }} Fs.close (); }}  


Comments