#pragma once #include "xlnt/xlnt.hpp" #include #include //excel文件操作类 class ExcelOP { public: ExcelOP(); ~ExcelOP(); //打开 bool OpenFile(QString& filePath); void saveFile(QString& filePath); //读指定sheet页数据 bool readSheetData(QString name, QList& result, bool& hasEmptyCell); //写指定sheet页数据,没有sheet页则新建 void writeSheetData(QString name, QList& input); //删除所有sheet void clearAllSheet(); // //新建sheet页 // void addSheet(QString name); // //设置当前的sheet页 // void getSheetByName(QString name); // void getSheetById(int id); // //设置表头 // void setSheetHead(std::string headName[]); //整行批量写入 // void setRowValue(int rowId, const QStringList& rowValue); // //设置指定单元格 // void setCell(int x, int y, std::string strValue); // //读出所有数据 // void readAllData(QList& rowVlaue); // //读出指定行数据 // void readRowValue(int y, QStringList& valuelist); // //读某指定单元格 // std::string readCell(int x, int y); // //获取总行数 // int totalRows(); // //获取总列数 // int totalColumns(); private: xlnt::workbook wb; xlnt::worksheet currentSheet; //当前操作的sheet页 };