You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
nmWATI/Include/iBase/iPlugin/WordEngine.h

66 lines
1.5 KiB
C

#pragma once
#include <QtCore>
#include <QAxBase>
#include <QAxObject>
#include "Defines.h"
#include "iPlugin_global.h"
// 该类实现word的导出主要借助dot模板来实现
class I_PLUGIN_EXPORT WordEngine : public QObject
{
Q_OBJECT
public:
WordEngine();
~WordEngine();
// 加载Dot文件如果为空则新建一个
bool open(QString sDotFile, bool bVisible = false);
// 替换标签(文本)
bool replaceText(QString sTag, QString sText);
// 替换标签(图片)
bool replaceImg(QString sTag, QString sImgFile);
// 替换标签(表格)
// 如果listHeaders为空则默认vvecData第一行为标题
// 否则listHeaders为标题vvecData全部为数据
bool replaceTable(QString sTag, \
VVecVariant& vvecData, \
QStringList listHeaders = QStringList());
// 保存
void saveAs(QString sFile);
private:
// 获取标签
QAxObject* getBookmarkOf(QString sTag);
// 表格相关操作
QAxObject* insertTableOf(QString sTag, int r, int c);
bool setTableCellStr(QAxObject* pTable, int r, int c, QString s);
bool setTableCellTextBold(QAxObject* pTable, int r, int c, bool b);
QAxObject* getTableCell(QAxObject* pTable, int r, int c);
// 释放内存
void release();
private:
// word about
QAxObject* m_pAxWord;
QAxObject* m_pAxDocs;
QAxObject* m_pAxDoc;
// Assit infos
QString m_sFile;
bool m_bOpen;
bool m_bNewDoc;
};