I want to export data from JTable to a file in CSV format. For read all data in TableModel i've used this:
for (int row = 0; row < rowCount; row++) {
for (int col = 0; col < columnCount; col++) {
csvData += tableModel.getValueAt(row, col);
csvData += col + 1 < columnCount ? "," : "";
}
csvData += "\r\n";
}
But for a large dataset the process is too slow. And i think the reason is not the loop itself, but getValueAt method that is slow.
So I ask if there is a faster way to get data from TableModel?