19 lines
662 B
C++
19 lines
662 B
C++
#include <qfile.h>
|
|
#include <string>
|
|
#define CsvHeadStr "时间,条码,相机名,总结果,撕裂,翻折,极耳宽,极耳高,焊印1,焊印2\r\n"
|
|
#define CRLF "\r\n"
|
|
void WriteToCsv(std::string filePath,std::vector<std::string> strList)
|
|
{
|
|
QFile CsvFile(QString::fromStdString(filePath));
|
|
bool FileExist = CsvFile.exists();
|
|
CsvFile.open(QIODevice::ReadWrite);
|
|
if (FileExist == false)
|
|
CsvFile.write(CsvHeadStr);
|
|
|
|
QByteArray qstr;
|
|
for (int cnt = 0; cnt <strList.size()-1;cnt++)
|
|
qstr.append(QByteArray::fromStdString(strList[cnt])+",");
|
|
qstr.append(QByteArray::fromStdString(strList[strList.size()-1]) + CRLF);
|
|
CsvFile.write(qstr);
|
|
CsvFile.close();
|
|
} |