GOAL: Realize a CSV Parsing, the code in the documentation works. But I want to edit it. In fact, I want to parse the values of a table called "Concert" I have in my database.
public class Excel extends BaseForm{
public Excel() throws IOException{
Form hi = new Form("CSV Parsing", new BorderLayout());
String[][] data = new String[100][3]; //[7ot max mta3 rows][max mta3 les attributs à afficher]
int i=0; //compteur mta3 lrows
ArrayList<Concert> list = ServiceConcert.getInstance().AffichageConcert();
for (Concert h : list) {
data[i][0] = h.getName();
data[i][1] = h.getIdmusician();
data[i][2] = h.getMusics(); // les attributs lezm ykounou String btw
i++; // bech tet3ada lel row li baadhha
}
String[] columnNames = new String[data[0].length];
for(int iter= 0 ; iter < columnNames.length ; iter++) {
columnNames[iter] = "Col " + (iter + 1);
}
System.out.println();
TableModel tm = new DefaultTableModel(columnNames, data);
hi.add(BorderLayout.CENTER, new Table(tm));
hi.show();
}
}
