qt Qxlsx 写入数据导致程序内存溢出 有知道原因的朋友请求帮帮忙 谢谢 代码如下
QXlsx::Document xlsxW(getFileName());
for(int = 0 ; < 10 ;++){
receiveData receive_data = dataQueue.dequeue();
xlsxW.selectSheet("battery_info");
xlsxW.write(_index,1,_index);
xlsxW.write(_index,2, receive_data.currentTime);
xlsxW.write(_index,3 ,receive_data.battery_vol);
xlsxW.write(_index,4 ,receive_data.battery_amp);
xlsxW.write(_index,5 ,receive_data.soc);
xlsxW.write(_index,6 ,receive_data.soh);
xlsxW.write(_index,7 ,receive_data.remain_capacity);
xlsxW.write(_index,8 ,receive_data.full_capcity);
xlsxW.write(_index,9 ,receive_data.cycyle_time);
int loop_index = 10;
for(int i = 0;i< receive_data.tempList.size();i++){
xlsxW.write(_index,loop_index,receive_data.tempList.at(i));
loop_index+=1;
}
xlsxW.deleteSheet("battery_info");
xlsxW.selectSheet("cell_vol");
xlsxW.write(_index,1,_index);
xlsxW.write(_index,2,receive_data.currentTime);
loop_index = 3;
for(int i = 0;i size();i++){
xlsxW.write(_index,loop_index,receive_data.cellsVol.at(i));
loop_index+=1;
}
xlsxW.deleteSheet("cell_vol");
xlsxW.selectSheet("status");
xlsxW.write(_index,1,_index);
xlsxW.write(_index,2,receive_data.currentTime);
xlsxW.write(_index,3 ,receive_data.sys_status.sys.sys_status_charge);
xlsxW.write(_index,4 ,receive_data.sys_status.sys.sys_status_discharge);
xlsxW.write(_index,5 ,receive_data.sys_status.sys.sys_status_effict_charge);
xlsxW.write(_index,6 ,receive_data.sys_status.sys.sys_status_effict_discharge);
xlsxW.write(_index,7 ,receive_data.sys_status.sys.sys_status_charge_current_limit);
xlsxW.write(_index,8 ,receive_data.sys_status.sys.sys_status_heat_film);
xlsxW.write(_index,9 ,receive_data.sys_status.sys.sys_status_acin);
xlsxW.write(_index,10,receive_data.sys_status.sys.sys_status_fully);
xlsxW.write(_index,11,receive_data.alarm_status.alarmStatus.alarm_status_cell_overcharge);
xlsxW.write(_index,12,receive_data.alarm_status.alarmStatus.alarm_status_cells_overcharge);
xlsxW.write(_index,13,receive_data.alarm_status.alarmStatus.alarm_status_cell_overdischarge);
xlsxW.write(_index,14,receive_data.alarm_status.alarmStatus.alarm_status_cells_overdischarge);
xlsxW.write(_index,15,receive_data.alarm_status.alarmStatus.alarm_status_single_diff_presure);
xlsxW.write(_index,16,receive_data.alarm_status.alarmStatus.alarm_status_charge_over_current);
xlsxW.write(_index,17,receive_data.alarm_status.alarmStatus.alarm_status_discharge_over_current);
xlsxW.write(_index,18,receive_data.alarm_status.alarmStatus.alarm_status_mos_hight_temp);
xlsxW.write(_index,19,receive_data.alarm_status.alarmStatus.alarm_status_env_hight_temp);
xlsxW.write(_index,20,receive_data.alarm_status.alarmStatus.alarm_status_env_low_temp);
xlsxW.write(_index,21,receive_data.alarm_status.alarmStatus.alarm_status_charge_hight_temp);
xlsxW.write(_index,22,receive_data.alarm_status.alarmStatus.alarm_status_charge_low_temp);
xlsxW.write(_index,23,receive_data.alarm_status.alarmStatus.alarm_status_discharge_hight_temp);
xlsxW.write(_index,24,receive_data.alarm_status.alarmStatus.alarm_status_discharge_low_temp);
xlsxW.write(_index,25,receive_data.charge_protect_status.chargeProtect.charge_protect_cell_ov);
xlsxW.write(_index,26,receive_data.charge_protect_status.chargeProtect.charge_protect_cells_ov);
xlsxW.write(_index,27,receive_data.charge_protect_status.chargeProtect.charge_protect_cells_oc);
xlsxW.write(_index,28,receive_data.charge_protect_status.chargeProtect.charge_protect_high_temp);
xlsxW.write(_index,29,receive_data.charge_protect_status.chargeProtect.charge_protect_low_temp);
xlsxW.write(_index,30,receive_data.discharge_protect_status.disChargeProtect.discharge_protect_cell_ov);
xlsxW.write(_index,31,receive_data.discharge_protect_status.disChargeProtect.discharge_protect_cells_ov);
xlsxW.write(_index,32,receive_data.discharge_protect_status.disChargeProtect.discharge_protect_oc);
xlsxW.write(_index,33,receive_data.discharge_protect_status.disChargeProtect.discharge_protect_short_cycle);
xlsxW.write(_index,34,receive_data.discharge_protect_status.disChargeProtect.discharge_protect_high_temp);
xlsxW.write(_index,35,receive_data.discharge_protect_status.disChargeProtect.discharge_protect_low_temp);
xlsxW.write(_index,36,receive_data.other_protect_status.otherProtect.other_protect_mos_high_temp);
xlsxW.write(_index,37,receive_data.other_protect_status.otherProtect.other_protect_env_high_temp);
xlsxW.write(_index,38,receive_data.other_protect_status.otherProtect.other_protect_env_low_temp);
xlsxW.write(_index,39,receive_data.other_protect_status.otherProtect.other_protect_cell_high_diff);
xlsxW.write(_index,40,receive_data.switch_status.swittch.swtich_set_charge_open);
xlsxW.write(_index,41,receive_data.switch_status.swittch.swtich_set_discharge_open);
xlsxW.write(_index,42,receive_data.switch_status.swittch.swtich_set_audibile_alert_open);
xlsxW.write(_index,43,receive_data.switch_status.swittch.swtich_set_lcd_alert_open);
xlsxW.deleteSheet("status");
_index+=1;
}
xlsxW.save();
}
for(int _index= 0 ; _index< 10 ;)
for循环改成这个
感觉导出时没有问题的。可能是在获取数据的时候导致内存激增
还有就是你可以使用2曾循环导出数据,没必要写这么多行的
我有149列的数据,那我还要写149行代码啊,那太麻烦了