Hallo sitze mal wieder vor einem GROSSEN ? 
Versuche gerade Daten aus Excel in ein TableView zu bringen. Die erste Spalte im Tableview wird gefüllt, aber die nachfolgenden nicht.
Hier mal der Code dazu:
Record Definition:
Definition TableColumn:
TableView Daten einfügen:
Also:
- "xlsDatas" ist definitiv gefüllt.
- im Record kommen die Daten auch an
- im Tableview wird aber nur die erste Splate angezeigt mit "Nachname, Vorname"
- es kommt auch keine Exception
Was übersieht mein Auge?
Versuche gerade Daten aus Excel in ein TableView zu bringen. Die erste Spalte im Tableview wird gefüllt, aber die nachfolgenden nicht.
Hier mal der Code dazu:
Record Definition:
Code:
package application;
import javafx.beans.property.*;
public class TableRecord {
private SimpleStringProperty UserName, azlWert;
private SimpleDoubleProperty azlJan, azlFeb, azlMar, azlApr, azlMai, azlJun, azlJul, azlAug, azlSep, azlOkt, azlNov, azlDez;
public String getUserName() {return UserName.get();}
public String getazlWert() {return azlWert.get();}
public Double getazlJan() {return azlJan.get();}
public Double getazlFeb() {return azlFeb.get();}
public Double getazlMar() {return azlMar.get();}
public Double getazlApr() {return azlApr.get();}
public Double getazlMai() {return azlMai.get();}
public Double getazlJun() {return azlJun.get();}
public Double getazlJul() {return azlJul.get();}
public Double getazlAug() {return azlAug.get();}
public Double getazlSep() {return azlSep.get();}
public Double getazlOkt() {return azlOkt.get();}
public Double getazlNov() {return azlNov.get();}
public Double getazlDev() {return azlDez.get();}
/**
* @param UserName String
* @param azlWert String
* @param azlJan String
* @param azlFeb String
* @param azlMar String
* @param azlApr String
* @param azlMai String
* @param azlJun String
* @param azlJul String
* @param azlAug String
* @param azlSep String
* @param azlOkt String
* @param azlNov String
* @param azlDez String
*/
public TableRecord(String UserName, String azlWert, Double azlJan, Double azlFeb, Double azlMar, Double azlApr,
Double azlMai, Double azlJun, Double azlJul, Double azlAug, Double azlSep, Double azlOkt, Double azlNov, Double azlDez) {
this.UserName = new SimpleStringProperty (UserName);
this.azlWert = new SimpleStringProperty (azlWert);
this.azlJan = new SimpleDoubleProperty (azlJan);
this.azlFeb = new SimpleDoubleProperty (azlFeb);
this.azlMar = new SimpleDoubleProperty (azlMar);
this.azlApr = new SimpleDoubleProperty (azlApr);
this.azlMai = new SimpleDoubleProperty (azlMai);
this.azlJun = new SimpleDoubleProperty (azlJun);
this.azlJul = new SimpleDoubleProperty (azlJul);
this.azlAug = new SimpleDoubleProperty (azlAug);
this.azlSep = new SimpleDoubleProperty (azlSep);
this.azlOkt = new SimpleDoubleProperty (azlOkt);
this.azlNov = new SimpleDoubleProperty (azlNov);
this.azlDez = new SimpleDoubleProperty (azlDez);
}
}
Definition TableColumn:
Code:
@SuppressWarnings({ "unchecked", "static-access", "rawtypes" })
private void createTableData() {
// Tabelle vorbereiten
TableColumn[] tableCol = new TableColumn[14];
int colIndex = 0;
tableCol[colIndex] = new TableColumn("Name");
tableCol[colIndex].setCellValueFactory(new PropertyValueFactory<>("UserName"));
colIndex++;
tableCol[colIndex] = new TableColumn("Bezeichnung");
tableCol[colIndex].setCellValueFactory(new PropertyValueFactory<>("azlWert"));
colIndex++;
tableCol[colIndex] = new TableColumn("Januar");
tableCol[colIndex].setCellValueFactory(new PropertyValueFactory<>("azlJan"));
colIndex++;
tableCol[colIndex] = new TableColumn("Februar");
tableCol[colIndex].setCellValueFactory(new PropertyValueFactory<>("azlFeb"));
colIndex++;
tableCol[colIndex] = new TableColumn("März");
tableCol[colIndex].setCellValueFactory(new PropertyValueFactory<>("azlMar"));
colIndex++;
tableCol[colIndex] = new TableColumn("April");
tableCol[colIndex].setCellValueFactory(new PropertyValueFactory<>("azlApr"));
colIndex++;
tableCol[colIndex] = new TableColumn("Mai");
tableCol[colIndex].setCellValueFactory(new PropertyValueFactory<>("azlMai"));
colIndex++;
tableCol[colIndex] = new TableColumn("Juni");
tableCol[colIndex].setCellValueFactory(new PropertyValueFactory<>("azlJun"));
colIndex++;
tableCol[colIndex] = new TableColumn("Juli");
tableCol[colIndex].setCellValueFactory(new PropertyValueFactory<>("azlJul"));
colIndex++;
tableCol[colIndex] = new TableColumn("August");
tableCol[colIndex].setCellValueFactory(new PropertyValueFactory<>("azlAug"));
colIndex++;
tableCol[colIndex] = new TableColumn("September");
tableCol[colIndex].setCellValueFactory(new PropertyValueFactory<>("azlSep"));
colIndex++;
tableCol[colIndex] = new TableColumn("Oktober");
tableCol[colIndex].setCellValueFactory(new PropertyValueFactory<>("azlOkt"));
colIndex++;
tableCol[colIndex] = new TableColumn("November");
tableCol[colIndex].setCellValueFactory(new PropertyValueFactory<>("azlNov"));
colIndex++;
tableCol[colIndex] = new TableColumn("Dezember");
tableCol[colIndex].setCellValueFactory(new PropertyValueFactory<>("azlDez"));
tableData.setItems(dataList);
tableData.getColumns().addAll(tableCol);
// TableView ins Stage einfügen
this.content.getChildren().addAll(tableData);
this.content.setTopAnchor(tableData, 0d);
this.content.setBottomAnchor(tableData, 0d);
this.content.setLeftAnchor(tableData, 0d);
this.content.setRightAnchor(tableData, 0d);
}
TableView Daten einfügen:
Code:
@FXML
public void importXLS() {
DirectoryChooser dirChooser = new DirectoryChooser();
File selDirectory = dirChooser.showDialog(null);
// Verzeichniss einlesen
ArrayList<File> files = helper.getimpFile(selDirectory);
if (files == null) return;
try {
for (File file : files) {
String fileName = file.getCanonicalPath();
this.lblStatus.setText("Analysiere " + fileName + "...");
this.xlsDatas = new Object[12][7];
if (!fileName.contains("Ruf")) {
if (!fileName.contains("$")) {
XLS_Helper xlsHelper = new XLS_Helper(file);
this.xlsDatas = xlsHelper.getXLSData();
System.out.println( xlsDatas[0][0].toString() + " | " + ("Summe Soll:").toString() + " | " + xlsDatas[0][1].toString() + " | " + xlsDatas[1][1].toString() + " | " +
xlsDatas[2][1].toString() + " | " + xlsDatas[3][1].toString() + " | " + xlsDatas[4][1].toString() + " | " + xlsDatas[5][1].toString() + " | " +
xlsDatas[6][1].toString() + " | " + xlsDatas[7][1].toString() + " | " + xlsDatas[8][1].toString() + " | " + xlsDatas[9][1].toString() + " | " +
xlsDatas[10][1].toString() + " | " + xlsDatas[11][1].toString());
// sysout ergibt:
// Nachname, Vorname | Summe Soll: | 168.0 | 160.0 | 184.0 | 144.0 | 168.0 | 160.0 | 168.0 | 184.0 | 168.0 | 160.0 | 168.0 | 152.0
TableRecord record = new TableRecord(
xlsDatas[0][0].toString(),
"Summe Soll:",
Double.parseDouble(xlsDatas[0][1].toString()),
Double.parseDouble(xlsDatas[1][1].toString()),
Double.parseDouble(xlsDatas[2][1].toString()),
Double.parseDouble(xlsDatas[3][1].toString()),
Double.parseDouble(xlsDatas[4][1].toString()),
Double.parseDouble(xlsDatas[5][1].toString()),
Double.parseDouble(xlsDatas[6][1].toString()),
Double.parseDouble(xlsDatas[7][1].toString()),
Double.parseDouble(xlsDatas[8][1].toString()),
Double.parseDouble(xlsDatas[9][1].toString()),
Double.parseDouble(xlsDatas[10][1].toString()),
Double.parseDouble(xlsDatas[11][1].toString())
);
dataList.add(record);
}
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
Also:
- "xlsDatas" ist definitiv gefüllt.
- im Record kommen die Daten auch an
- im Tableview wird aber nur die erste Splate angezeigt mit "Nachname, Vorname"
- es kommt auch keine Exception
Was übersieht mein Auge?