2025-06-05 11:30:12 +08:00
|
|
|
//#include <appCore.hpp>
|
2025-03-21 18:25:54 +08:00
|
|
|
#include <writeExcel.h>
|
|
|
|
|
#include <global.h>
|
|
|
|
|
|
2025-03-28 18:33:43 +08:00
|
|
|
//std::vector < std::pair<std::string, std::string>> writeExcelLoop(XLWorksheet& sheet, customExcelStruct& input, int depth, int cols)
|
|
|
|
|
//{
|
|
|
|
|
// std::vector < std::pair<std::string, std::string>> mergeStr;
|
|
|
|
|
// std::string startUnit = char(65 + depth) + std::to_string(cols);
|
|
|
|
|
// int depthCount = 0;
|
|
|
|
|
// for (int i = 0; i < input.nexCols.size(); i++)
|
|
|
|
|
// {
|
|
|
|
|
// std::vector < std::pair<std::string, std::string>>
|
|
|
|
|
// sonMerges = writeExcelLoop(sheet, input.nexCols[i], depth + 1, cols + depthCount);
|
|
|
|
|
// mergeStr.insert(mergeStr.end(), sonMerges.begin(), sonMerges.end());
|
2025-11-10 01:16:58 +08:00
|
|
|
// depthCount += std::max((int)input.nexCols[i].nexCols.size(), 1);
|
2025-03-28 18:33:43 +08:00
|
|
|
// }
|
2025-11-10 01:16:58 +08:00
|
|
|
// std::string endUnit = char(65 + depth) + std::to_string(cols + std::max(depthCount - 1, 0));
|
2025-03-28 18:33:43 +08:00
|
|
|
// sheet.cell(startUnit).value() = input.text;
|
|
|
|
|
// mergeStr.push_back(std::make_pair(startUnit, endUnit));
|
|
|
|
|
// return mergeStr;
|
|
|
|
|
//}
|
|
|
|
|
//void writeExcel(std::string path, std::string sheetName, std::vector<std::string> titles, customExcelStruct input)
|
|
|
|
|
//{
|
|
|
|
|
// std::vector<std::pair<std::string, std::string>> mergeStr(0);
|
|
|
|
|
// try {
|
|
|
|
|
// fileManager::setFileReadOnly(path, false);
|
|
|
|
|
// XLDocument doc;
|
|
|
|
|
// if (std::filesystem::exists(path) == true)
|
|
|
|
|
// doc.open(path);
|
|
|
|
|
// else
|
|
|
|
|
// doc.create(path);
|
|
|
|
|
// if (doc.workbook().worksheetExists(sheetName) == false)
|
|
|
|
|
// doc.workbook().addWorksheet(sheetName);
|
|
|
|
|
// auto sheet = doc.workbook().worksheet(sheetName);
|
|
|
|
|
// int lastrow = sheet.rowCount();
|
|
|
|
|
// if (lastrow == 0)
|
|
|
|
|
// {
|
|
|
|
|
// auto sheet = doc.workbook().worksheet(sheetName);
|
|
|
|
|
// for (int i = 0; i < titles.size(); i++)
|
|
|
|
|
// {
|
|
|
|
|
// std::string unit = char(65 + i) + std::string("1");
|
|
|
|
|
// sheet.cell(unit).value() = titles[i];
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// lastrow = sheet.rowCount();
|
|
|
|
|
//
|
|
|
|
|
// mergeStr = writeExcelLoop(sheet, input, 0, lastrow + 1);
|
|
|
|
|
// doc.save();
|
|
|
|
|
// doc.close();
|
|
|
|
|
// }
|
|
|
|
|
// catch (const std::exception& e) {
|
|
|
|
|
// std::cerr << "An error occurred: " << e.what() << std::endl;
|
|
|
|
|
// fileManager::setFileReadOnly(path, true);
|
|
|
|
|
// }
|
|
|
|
|
// /*for (auto &str : mergeStr)
|
|
|
|
|
// if(str.second.compare(""))
|
|
|
|
|
// _core._pythonCpp.runPythonScript("./pyScript/mergeExcelCells.py", { path,sheetName, str.first, str.second });*/
|
|
|
|
|
// fileManager::setFileReadOnly(path, true);
|
|
|
|
|
//}
|