params.append(3); //行数 params.append(4); //列数 //表格对象 QAxObject* datatable = tables->querySubObject("Add(QAxObject*, int, int, QVariant&, QVariant&)", params); datatable->setProperty("Style", "网格型"); //设置表头 QAxObject* rangeTitle = datatable->querySubObject("Cell(int, int)", 1, 1)->querySubObject("Range"); rangeTitle->querySubObject("ParagraphFormat")->setProperty("Alignment", "wdAlignParagraphCenter"); rangeTitle->querySubObject("Font")->setProperty("Size", 10.5); rangeTitle->dynamicCall("SetText(QString)", QStringLiteral("序号")); rangeTitle = datatable->querySubObject("Cell(int, int)", 1, 2)->querySubObject("Range"); rangeTitle->querySubObject("ParagraphFormat")->setProperty("Alignment", "wdAlignParagraphCenter"); rangeTitle->querySubObject("Font")->setProperty("Size", 10.5); rangeTitle->dynamicCall("SetText(QString)", QStringLiteral("测量值")); rangeTitle = datatable->querySubObject("Cell(int, int)", 1, 3)->querySubObject("Range"); rangeTitle->querySubObject("ParagraphFormat")->setProperty("Alignment", "wdAlignParagraphCenter"); rangeTitle->querySubObject("Font")->setProperty("Size", 10.5); rangeTitle->dynamicCall("SetText(QString)", QStringLiteral("理论值"));帮我改成六列五行,表头分别是:序号、孔深(m)、倾角、方位角、上下偏差、左右偏差
时间: 2024-04-15 16:03:25 浏览: 101
好的,我帮你修改代码。修改后的代码如下:
```cpp
params.append(5); //行数
params.append(6); //列数
//表格对象
QAxObject* datatable = tables->querySubObject("Add(QAxObject*, int, int, QVariant&, QVariant&)", params);
datatable->setProperty("Style", "网格型");
//设置表头
QAxObject* rangeTitle = datatable->querySubObject("Cell(int, int)", 1, 1)->querySubObject("Range");
rangeTitle->querySubObject("ParagraphFormat")->setProperty("Alignment", "wdAlignParagraphCenter");
rangeTitle->querySubObject("Font")->setProperty("Size", 10.5);
rangeTitle->dynamicCall("SetText(QString)", QStringLiteral("序号"));
rangeTitle = datatable->querySubObject("Cell(int, int)", 1, 2)->querySubObject("Range");
rangeTitle->querySubObject("ParagraphFormat")->setProperty("Alignment", "wdAlignParagraphCenter");
rangeTitle->querySubObject("Font")->setProperty("Size", 10.5);
rangeTitle->dynamicCall("SetText(QString)", QStringLiteral("孔深(m)"));
rangeTitle = datatable->querySubObject("Cell(int, int)", 1, 3)->querySubObject("Range");
rangeTitle->querySubObject("ParagraphFormat")->setProperty("Alignment", "wdAlignParagraphCenter");
rangeTitle->querySubObject("Font")->setProperty("Size", 10.5);
rangeTitle->dynamicCall("SetText(QString)", QStringLiteral("倾角"));
rangeTitle = datatable->querySubObject("Cell(int, int)", 1, 4)->querySubObject("Range");
rangeTitle->querySubObject("ParagraphFormat")->setProperty("Alignment", "wdAlignParagraphCenter");
rangeTitle->querySubObject("Font")->setProperty("Size", 10.5);
rangeTitle->dynamicCall("SetText(QString)", QStringLiteral("方位角"));
rangeTitle = datatable->querySubObject("Cell(int, int)", 1, 5)->querySubObject("Range");
rangeTitle->querySubObject("ParagraphFormat")->setProperty("Alignment", "wdAlignParagraphCenter");
rangeTitle->querySubObject("Font")->setProperty("Size", 10.5);
rangeTitle->dynamicCall("SetText(QString)", QStringLiteral("上下偏差"));
rangeTitle = datatable->querySubObject("Cell(int, int)", 1, 6)->querySubObject("Range");
rangeTitle->querySubObject("ParagraphFormat")->setProperty("Alignment", "wdAlignParagraphCenter");
rangeTitle->querySubObject("Font")->setProperty("Size", 10.5);
rangeTitle->dynamicCall("SetText(QString)", QStringLiteral("左右偏差"));
```
这样,表格的行数变为了五行,列数变为了六列,并且表头分别是:序号、孔深(m)、倾角、方位角、上下偏差、左右偏差。
阅读全文