|
@@ -54,7 +54,9 @@ bool ExportReportManager::exportReport()
|
|
|
|
|
|
insertCommonInfo();
|
|
|
if (m_evalType == ProjectManager::OptimalEval) {
|
|
|
- insertSchemeInfo();
|
|
|
+ insertSchemeDesignInfo();
|
|
|
+ insertSchemeIndex();
|
|
|
+ insertSchemeData();
|
|
|
}
|
|
|
|
|
|
m_word->setVisible(true);
|
|
@@ -110,7 +112,7 @@ void ExportReportManager::insertCommonInfo()
|
|
|
insertText("bmEvalPurpose", m_proj->estimateObjective);
|
|
|
}
|
|
|
|
|
|
-void ExportReportManager::insertSchemeInfo()
|
|
|
+void ExportReportManager::insertSchemeDesignInfo()
|
|
|
{
|
|
|
QList<SchemaEval *> schemeList;
|
|
|
bool ret = SchemeInfoService().QuerySchemeInfoByEngineerId(&schemeList, m_proj->id, 0);
|
|
@@ -160,11 +162,34 @@ void ExportReportManager::insertSchemeInfo()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+void ExportReportManager::insertSchemeIndex()
|
|
|
+{
|
|
|
+ insertText("bmProjName31", m_proj->projectName);
|
|
|
+ insertText("bmProjName32", m_proj->projectName);
|
|
|
+
|
|
|
+ // bmIndexTable
|
|
|
+ QAxObject *table = insertTable("bmIndexTable", 15, 5);
|
|
|
+ if (table == nullptr) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ m_word->setFontName(QString::fromLocal8Bit("仿宋_GB2312"));
|
|
|
+ m_word->setFontSize(9);
|
|
|
+ m_word->setParagraphAlignment(0);
|
|
|
+ setCellString(table, 1, 1, "index");
|
|
|
+ mergeCells(table, 1, 1, 2, 2);
|
|
|
+ setCellString(table, 3, 1, "index2");
|
|
|
+}
|
|
|
+
|
|
|
+void ExportReportManager::insertSchemeData()
|
|
|
+{
|
|
|
+ insertText("bmProjName41", m_proj->projectName);
|
|
|
+}
|
|
|
+
|
|
|
bool ExportReportManager::insertText(const QString &bookmark, const QString &text)
|
|
|
{
|
|
|
bool ret = false;
|
|
|
- QAxObject *doc = m_word->getWordApp()->querySubObject("ActiveDocument");
|
|
|
- QAxObject *bmProjName = doc->querySubObject("Bookmarks(QVariant)", bookmark);
|
|
|
+ QAxObject *bmProjName = m_word->getDocument()->querySubObject("Bookmarks(QVariant)", bookmark);
|
|
|
|
|
|
if (bmProjName != nullptr) {
|
|
|
bmProjName->dynamicCall("Select(void)");
|
|
@@ -173,3 +198,60 @@ bool ExportReportManager::insertText(const QString &bookmark, const QString &tex
|
|
|
}
|
|
|
return ret;
|
|
|
}
|
|
|
+
|
|
|
+QAxObject *ExportReportManager::insertTable(QString bookmark, int row, int column)
|
|
|
+{
|
|
|
+ QAxObject *bmTable = m_word->getDocument()->querySubObject("Bookmarks(QVariant)", bookmark);
|
|
|
+ if (bmTable) {
|
|
|
+ bmTable->dynamicCall("Select(void)");
|
|
|
+ QAxObject *selection = m_word->getWordApp()->querySubObject("Selection");
|
|
|
+ if (!selection)
|
|
|
+ return nullptr;
|
|
|
+
|
|
|
+ selection->dynamicCall("InsertAfter(QString&)", "\n");
|
|
|
+ // selection->dynamicCall("MoveLeft(int)", 1);
|
|
|
+ selection->querySubObject("ParagraphFormat")->dynamicCall("Alignment", "wdAlignParagraphCenter");
|
|
|
+ // selection->dynamicCall("TypeText(QString&)", "Table Test"); //设置标题
|
|
|
+
|
|
|
+ QAxObject *range = selection->querySubObject("Range");
|
|
|
+ QAxObject *tables = m_word->getDocument()->querySubObject("Tables");
|
|
|
+ QAxObject *table = tables->querySubObject("Add(QVariant,int,int)", range->asVariant(), row, column);
|
|
|
+ if (!tables)
|
|
|
+ return nullptr;
|
|
|
+
|
|
|
+ for (int i = 1; i <= 6; i++) {
|
|
|
+ QString str = QString("Borders(-%1)").arg(i);
|
|
|
+ QAxObject *borders = table->querySubObject(str.toLocal8Bit().constData());
|
|
|
+ borders->dynamicCall("SetLineStyle(int)", 1);
|
|
|
+ }
|
|
|
+ return table;
|
|
|
+ }
|
|
|
+
|
|
|
+ return nullptr;
|
|
|
+}
|
|
|
+
|
|
|
+void ExportReportManager::setCellString(QAxObject *table, int row, int column, const QString &text)
|
|
|
+{
|
|
|
+ if (table == nullptr) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ table->querySubObject("Cell(int,int)", row, column)->querySubObject("Range")->dynamicCall("SetText(QString)", text);
|
|
|
+}
|
|
|
+
|
|
|
+void ExportReportManager::mergeCells(QAxObject *table, int row, int column, int rowSpan, int columnSpan)
|
|
|
+{
|
|
|
+ if (table == nullptr) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ QAxObject *startCell = table->querySubObject("Cell(int, int)", row, column);
|
|
|
+ QAxObject *endCell = table->querySubObject("Cell(int, int)", row + rowSpan - 1, column + columnSpan - 1);
|
|
|
+ if (nullptr == startCell) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (nullptr == endCell) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ startCell->querySubObject("Merge(LPDISPATCH)", endCell->asVariant());
|
|
|
+}
|