how to solve java.io.IOException

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vikassawant
    New Member
    • Mar 2009
    • 27

    how to solve java.io.IOException

    hi,
    I am trying to import excel file in JTable.For that I used following code,

    import com.zfqjava.swi ng.*;
    import org.apache.poi. hssf.usermodel. *;
    import org.apache.poi. hssf.usermodel. HSSFSheet;
    import org.apache.poi. hssf.usermodel. HSSFWorkbook;
    import org.apache.poi. poifs.filesyste m.POIFSFileSyst em;


    FileDialog fd=new FileDialog(new Frame());

    fd.setMode(File Dialog.LOAD);
    fd.setTitle("Op en");
    fd.show();
    String nm=fd.getFile() ;
    System.out.prin tln(nm);

    try{

    POIFSFileSystem fs=new POIFSFileSystem (new FileInputStream (nm));
    HSSFWorkbook wb=new HSSFWorkbook(fs );
    FileOutputStrea m fileOut = new FileOutputStrea m(nm);
    wb.write(fileOu t);
    fileOut.close() ;
    System.out.prin tln("Your excel file has been generated");

    } catch ( Exception ex )
    {
    System.out.prin tln(ex);
    }



    Error is-

    java.io.IOExcep tion : Invalid header signature;read 795465215648951 542, expectd -222498542445424 15674896

    what is wrong here?

    Thanks in advance.
  • NitinSawant
    Contributor
    • Oct 2007
    • 271

    #2
    http://www.zfqjava.com/article/How-t...to-JTabel.html might help you.



    regards,
    Nitin Sawant

    Comment

    • JosAH
      Recognized Expert MVP
      • Mar 2007
      • 11453

      #3
      Originally posted by vikassawant
      java.io.IOExcep tion : Invalid header signature;read 795465215648951 542, expectd -222498542445424 15674896
      Are you trying to read an Excel MS Office 2007 file? Try to write the file as an earlier version.

      kind regards,

      Jos

      Comment

      Working...