#ifndef READEXCEL_H #define READEXCEL_H #include #include #include #include #include #include #include class Position { public: Position() { m_row = 0; m_col = 0; } Position(int row, int col) { m_row = row; m_col = col; } public: int m_row; int m_col; public: bool operator<(const Position & ct) const // 两个const是必需的。 { if (m_row < ct.m_row) { return true; } else if (m_row == ct.m_row) { if ( m_col < ct.m_col ) { return true; } } return false; } }; class ReadExcel { public: ReadExcel(); ~ReadExcel(); public: //打开excel文件 bool openExcel(const QString& filename); void getALLfromDirNormalExcel(QString strFileName); bool openExcelForWrite(const QString &filename); //获取 指定单元格的数据 std::string getCellData(const int& row, const int& col); int WriteCellData(const int& row, const int& col,std::string strValue ); //获取 行数,列数 void getInfo(int& row, int& col) const; private: void getALLfromExcel(); void WriteALLfromExcel(); private: int m_row; //行 int m_col; //列 QString m_filename; QAxObject* m_excel; int m_rowWrite; //行 int m_colWrite; //列 QAxObject* m_excelWrite; std::map m_mapdata; std::map m_mapdataWrite; Position p; }; #endif // READEXCEL_H