チャートとテーブルにいくつかのデータを表示するアプリケーションを作成しています。ここで、ユーザーがデータをテーブルからコピーしてExcelに挿入できるようにします。私のコピー機能は正常に動作しますが、出力には多少問題があります。
たとえば、次の表をコピーしたい場合:

Excelで次の出力が得られます。

わからない場合は、Excelの1列にデータが表示されます。
Excelに貼り付けたときに各データが別々の列に表示されるように、正しい出力を実現する方法を知っている人はいますか?
以下は、私がコピーするために使用するコードです。
table.getSelectionModel().setCellSelectionEnabled(true);
table.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
MenuItem item = new MenuItem("Kopiér");
item.setOnAction(new EventHandler<ActionEvent>() {
    @Override
    public void handle(ActionEvent event) {
        ObservableList<TablePosition> posList = table.getSelectionModel().getSelectedCells();
        int old_r = -1;
        StringBuilder clipboardString = new StringBuilder();
        for (TablePosition p : posList) {
            int r = p.getRow();
            int c = p.getColumn();
            Object cell = table.getColumns().get(c).getCellData(r);
            if (cell == null)
                cell = "";
            if (old_r == r)
                clipboardString.append('\t');
            else if (old_r != -1)
                clipboardString.append('\n');
            clipboardString.append(cell);
            old_r = r;
        }
        final ClipboardContent content = new ClipboardContent();
        System.out.println(clipboardString);
        content.putString(clipboardString.toString());
        Clipboard.getSystemClipboard().setContent(content);
    }
});
MenuItem item2 = new MenuItem("Kopier række");
item2.setOnAction(new EventHandler<ActionEvent>() {
    @Override
    public void handle(ActionEvent event) {
        String rowContent = "";
        ObservableList<TablePosition> posList = table.getSelectionModel().getSelectedCells();
        System.out.println(rowContent);
        for (TablePosition p : posList) {
            int c = 1;
            int row = p.getRow();
            System.out.println("c " +c);
            System.out.println("row "+row);
            for (int i = 1; i < table.getColumns().size(); i++) {
                rowContent = rowContent +" "+table.getColumns().get(c).getCellData(row);
                if (c < 13) {
                    c++;            
                }   
            }       
        }
        final ClipboardContent allContent = new ClipboardContent();
        allContent.putString(rowContent.toString());
        Clipboard.getSystemClipboard().setContent(allContent);
        System.out.println(allContent.toString());
        rowContent = "";
    }
});
ContextMenu menu = new ContextMenu();
menu.getItems().addAll(item,item2);
