DPS/DataPlatform/ExcelOP.h

54 lines
1.3 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#pragma once
#include "xlnt/xlnt.hpp"
#include <QString>
#include <QList>
//excel文件操作类
class ExcelOP
{
public:
ExcelOP();
~ExcelOP();
//打开
bool OpenFile(QString& filePath);
void saveFile(QString& filePath);
//读指定sheet页数据
bool readSheetData(QString name, QList<QStringList>& result, bool& hasEmptyCell);
//写指定sheet页数据没有sheet页则新建
void writeSheetData(QString name, QList<QStringList>& 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<QStringList>& 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页
};