2025-06-17T10:48:14

This commit is contained in:
yuntang 2025-06-17 10:48:15 +08:00
parent ea533c0fff
commit bfbf12cf2e
7 changed files with 50 additions and 7 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -44,7 +44,7 @@ int XlsxHandler::readFile(const QString filePath, Global::CurveFileData &cfd)
_currentFilePath = filePath;
// cfd.fileName = fileInfo.fileName();
// cfd.fileName = fileInfo.fileName();
cfd.filePath = filePath;
QXlsx::Document xlsx(filePath);
@ -307,6 +307,7 @@ void XlsxHandler:: xlsxFileAppendAnalysisOperation(const QString filePath)
logde << "current sheet is empty.";
return;
}
int index = sheet->dimension().lastRow();
logde<<"lastRow:"<<index;
@ -606,11 +607,11 @@ void XlsxHandler::writeSmoothnessFile(const QString filePath)
// logde<<"Global::_curveExperimentDataVtr size:"
// <<Global::_curveExperimentDataVtr.size();
QVector<Global::ExperimentData> edVtr =
QVector<Global::ExperimentData> edVtr =
phaseVtr.at(i).dataVtr;
if(!phaseVtr.at(i).smoothDataVtr.empty()){
edVtr = phaseVtr.at(i).smoothDataVtr;
}
if(!phaseVtr.at(i).smoothDataVtr.empty()){
edVtr = phaseVtr.at(i).smoothDataVtr;
}
// phase data size.
dataSizeRow = row;
@ -655,6 +656,9 @@ void XlsxHandler::writeXlsxFile(const QString filePath)
QVector<Global::PhaseTotalInfo>& phaseVtr =
Global::_curveFileDataVtr.first().phaseTotalVtr;
writeSmoothnessFile(filePath);
#if 0
if(phaseVtr.first().smoothDataVtr.empty()){
logde<<"xlsx file data smooth vtr is empty.";
xlsxFileAppendAnalysisOperation(filePath);
@ -662,4 +666,38 @@ void XlsxHandler::writeXlsxFile(const QString filePath)
logde<<"xlsx file data smooth vtr is not empty.";
writeSmoothnessFile(filePath);
}
#endif
}
int XlsxHandler::deleteInvalidRow(QXlsx::Document *doc)
{
QXlsx::Worksheet *sheet = doc->currentWorksheet();
if(!sheet)
{
logde << "current sheet is empty.";
return 0;
}
int lastRow = doc->dimension().lastRow();
logde<<"lastRow:"<<lastRow;
int startRow = lastRow - 19; // 倒数第20行
for (int row = lastRow; row >= startRow; --row) {
QString cellValue = sheet->read(row, 0).toString();
if (cellValue.isEmpty()
|| cellValue == ConAnalysisOperationCount
|| cellValue == AnaOpRecorder::NumericalLabelStr
|| cellValue == AnaOpRecorder::StartPointStr
|| cellValue == AnaOpRecorder::StopPointStr
|| cellValue == AnaOpRecorder::PeakSynthesisAnalysisStr
|| cellValue == AnaOpRecorder::GlassTransitionStr
|| cellValue == AnaOpRecorder::OnsetTemperaturePointStr
|| cellValue == AnaOpRecorder::EndsetTemperaturePointStr
) {
qDebug() << "Row" << row << "is empty or contains specified string. Deleting row.";
// sheet->deleteRows(row, 1); // 删除当前行
// sheet->deleteRow(row);
}
}
}

View File

@ -32,6 +32,9 @@ namespace XlsxHandler {
void writeAnalysisOperationDetail(QXlsx::Document*doc,const int row);
// discard
int deleteInvalidRow(QXlsx::Document*doc);
extern QString _currentFilePath;
const QString ConUnitMg = "mg";

View File

@ -574,14 +574,14 @@ void CentralWidget::uiLoadXlsxFileData()
#if 1
// Load xlsx file data.
QVector<ExperimentData> allDataVtr;
for(Global::CurveFileData& cfd:Global::_curveFileDataVtr){
for(int i = 0;i < cfd.phaseTotalVtr.size();i++){
Global::PhaseTotalInfo& pti = cfd.phaseTotalVtr[i];
PointCalculate::setAnalysisData(pti.dataVtr);
allDataVtr.append(pti.dataVtr);
// Load data.
QVector<Global::ExperimentData> dataVtr;
QVector<double> tVtr,xVtr, yVtr;
int index = 0;
for (Global::ExperimentData &ed : pti.dataVtr)
@ -624,6 +624,8 @@ void CentralWidget::uiLoadXlsxFileData()
pti.curve = _currentCurve;
}
PointCalculate::setAnalysisData(allDataVtr);
// Add analysis operation data.
if(cfd.analysisOperationVtr.size() > 0){
for(AnaOpRecorder::AnalysisOperation& ao