JFileChooser fc = new JFileChooser();
int option = fc.showSaveDialog(NewJFrame1.this);
if(option == JFileChooser.APPROVE_OPTION){
String filename = fc.getSelectedFile().getName();
String path = fc.getSelectedFile().getParentFile().getPath();
int len = filename.length();
String ext = "";
String file = "";
if(len > 4){
ext = filename.substring(len-4, len);
}
if(ext.equals(".xls")){
file = path + "\\" + filename;
}else{
file = path + "\\" + filename + ".xls";
}
toExcel(jTable1, new File(file));
}
this is how i save my table to excel it works fine but i want to import these datas after i restart my program can someone help me about this ?
You can use Apache POI to export your JTable Data.
See how to do it here, in this thread: apache poi: saving jtable to a file
I didn't read your question, if you're trying to IMPORT data, try these methods: http://www.zfqjava.com/article/How-to-import-excel-into-JTabel.html