Simple implementation of CSV export.
This commit is contained in:
@ -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:
|
||||
|
||||
Reference in New Issue
Block a user