Re: How can i save the JTable data in an Excel file 
Author: goforjava 
In Reply To: How can i save the JTable data in an Excel file  Aug 26, 2002 1:12 AM   Reply 1 of 8   
 
 
I posted a similar question few days back but no replies.
Then did some digging onto info on net.
You can save information in CSV format which states as to which delimiters are to be used and other things. You can use either ; or tab or ,. And enclose each field in double quotes. After each row add a newline windows new line ( \r\n) Tabs are best as far as seperators are concerned coz' EXCEL reads file saved with tab as seperator without asking for delimiters. Try saving an EXCEL file in CSV format through EXCEL and then open in notepad u'll come to know the format.If u need i could send that open source link which i used for writing table values in CSV format. regards,
Amit.
 
 
Re: How can i save the JTable data in an Excel file 
Author: srv7 
In Reply To: Re: How can i save the JTable data in an Excel file  Aug 26, 2002 5:47 AM   Reply 6 of 8   
 
 
m.save.addActionListener(new ActionListener(){ //Start save action listener and dialog box
public void actionPerformed(ActionEvent e){
fc = new JFileChooser();
fc.setCurrentDirectory(new File("C:\\"));
fc.setSelectedFile(new File("*.csv"));
int retMethod = fc.showSaveDialog(fc);
int nRows = jt.getRowCount();
int nCols = jt.getColumnCount();
File f = fc.getSelectedFile();for (int i = 0; i < nRows; i++){ //Loop through rowsfor (int j = 0; j < nCols; j++){ //Loop throught columnss+=(String)jt.getValueAt(i,j)+","; //Put the values in a comma seperated format
}
}
if (retMethod == JFileChooser.APPROVE_OPTION){try{
FileWriter fw = new FileWriter(f);
fw.write(s);
fw.flush();
fw.close();

catch(IOException ioe){}
}
}
}); U go thru this one's..