我想格式化Microsoft 2010单元格注释(例如更改字体、大胆、.)使用Qt 5。
我可以使用以下代码向单元格添加注释:
QAxObject* cellRange = m_activeWorksheet->querySubObject("Cells(int, int)", row, col);
cellRange->dynamicCall("AddComment(const QVariant&)", comment);我还可以为单元格注释设置AutoSize属性:
QAxObject* axComment = cellRange->querySubObject("Comment");
QAxObject* shape = axComment->querySubObject("Shape");
shape->querySubObject("TextFrame")->setProperty("AutoSize", autosize);但我无法更改“更深层次”的注释属性,例如TextFrame.Characters.Font.Bold。
设置单元格注释后,命令
shape->querySubObject("TextFrame") 返回一个非零指针,但是
shape->querySubObject("TextFrame")->querySubObject("Characters")返回NULL。
如何使用QAxObject格式化单元格注释?是否有QAxObject可访问的不同QAxObject的属性/子对象的描述?
以下代码没有任何效果:
shape->setProperty("AutoShapeType", 5);发布于 2014-10-24 17:05:47
Characters。相反,它有方法Characters,但是它的完全签名是
字符(开始,长度)
应该指定完全签名的Qt 他说,因此您可能应该使用
shape->querySubObject("TextFrame")->querySubObject("Characters(Start,长度)“)AutoShapeType设置为5。AutoShapeType的类型为MsoAutoShapeType,只允许指定值。发布于 2014-10-29 19:59:00
浏览完Qt文档之后,QAxBase dynamicCAll部分展示了如何使用动态调用设置Excel单元格注释的形状:
QString comment("My comment");
QAxObject* cellRange = m_activeWorksheet->querySubObject("Cells(int, int)", cellRow, cellColumn);
cellRange->dynamicCall("AddComment(const QVariant&)", comment);
QAxObject* axComment = cellRange->querySubObject("Comment");
QAxObject* shape = axComment->querySubObject("Shape");
shape->dynamicCall("AutoShapeType", 5);这个值可以从Lol4t0的链接:MsoAutoShapeType枚举中找到。在这里,5是用来得到一个圆形矩形(msoShapeRoundedRectangle)。下面是更改文本注释格式的剩余代码:
QAxObject* textFrame = shape->querySubObject("TextFrame");
QAxObject* chars = textFrame->querySubObject("Characters(int, int)", 1, comment.size());
QAxObject* font = chars->querySubObject("Font");
font->setProperty("Bold", false);
shape->querySubObject("TextFrame")->querySubObject("Characters(2, 3)")->querySubObject("Font")->setProperty("Size", 24);https://stackoverflow.com/questions/26341604
复制相似问题