Hi,
Am a new comer on this forum and I need your help please!
I want to export to Excel a JTable datas. This is the code:
public class JExporter {
public void exporter(JTable table, File file)
{
try
{
TableModel model = table.getModel();
FileWriter out = new FileWriter(file);
for(int i=0; i < model.getColumnCount(); i++) {
out.write(model.getColumnName(i) +"\t");
}
out.write("\n");
for(int i=0; i< model.getRowCount(); i++) {
for(int j=0; j<model.getColumnCount(); j++) {
Object value=model.getValueAt(i,j);
if ( value!=null ){
out.write(value.toString()+"\t");
}
else
{
out.write(" ");
}
out.write("\n");
}
}
out.close();
} catch(Exception err){
err.printStackTrace();
}
}
}
But when I try to export data, it fall into a single columm. please help me to export my datas solving this for me