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.
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.
Comment