By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,658 Members | 1,255 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,658 IT Pros & Developers. It's quick & easy.

how to solve java.io.IOException

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

import com.zfqjava.swing.*;
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.filesystem.POIFSFileSystem;


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

fd.setMode(FileDialog.LOAD);
fd.setTitle("Open");
fd.show();
String nm=fd.getFile();
System.out.println(nm);

try{

POIFSFileSystem fs=new POIFSFileSystem(new FileInputStream(nm));
HSSFWorkbook wb=new HSSFWorkbook(fs);
FileOutputStream fileOut = new FileOutputStream(nm);
wb.write(fileOut);
fileOut.close();
System.out.println("Your excel file has been generated");

} catch ( Exception ex )
{
System.out.println(ex);
}



Error is-

java.io.IOException : Invalid header signature;read 795465215648951542, expectd -22249854244542415674896

what is wrong here?

Thanks in advance.
Mar 19 '09 #1
Share this Question
Share on Google+
2 Replies


100+
P: 269
http://www.zfqjava.com/article/How-t...to-JTabel.html might help you.



regards,
Nitin Sawant
Mar 20 '09 #2

Expert 10K+
P: 11,448
@vikassawant
Are you trying to read an Excel MS Office 2007 file? Try to write the file as an earlier version.

kind regards,

Jos
Mar 21 '09 #3

Post your reply

Sign in to post your reply or Sign up for a free account.