Simple implementation of CSV export.

This commit is contained in:
2026-01-06 10:04:26 +01:00
parent 3e6273cb7d
commit 99ed398c2f
8 changed files with 46 additions and 0 deletions

View File

@ -21,6 +21,24 @@ QList<ModelItemValues> CsvParser::getItemsFromCSVFile(const QString& fileName) {
}
}
bool CsvParser::exportToCSVFile(const QList<QStringList>& rows, const QString& filePath) {
Document doc(std::string(), LabelParams(0, -1));
const QList<QString> headerNames = GET_HEADER_NAMES();
for (int column = 0; column < headerNames.size(); ++column) {
doc.SetColumnName(column, headerNames.at(column).toStdString());
}
for (int row = 0; row < rows.size(); ++row) {
QStringList rowValues = rows.at(row);
std::vector<std::string> rowValueStrings;
for (int column = 0; column < rowValues.size(); ++column) {
rowValueStrings.push_back(rowValues.at(column).toStdString());
}
doc.InsertRow(row, rowValueStrings);
}
doc.Save(filePath.toStdString());
return true;
}
CsvParser::CsvParser() {}
/** A CSV file is compatible if the following is true: