Please nominate your Qt Champions for 2021! https://forum.qt.io/topic/132134/looking-for-the-2021-qt-champions

Creating and adding values to Chart in Word C++ ActiveQT



  • Hello everybody,

    I need add a chart to my word document with some custom values for the chart, what I have managed to do is only add a new chart where the excel spreadsheet pop up and and add that into my document, but the problem is that I want to add those values programmatically, I searched almost everything and couldn't find!
    Can any of you help?
    The code is as below:
    @
    QString outFile("D:\output.docx");
    QString inFile1("D:\input.docx");
    QAxObject axObject("Word.Application");
    QAxObject* documents = axObject.querySubObject("Documents");
    QAxObject* document = documents->querySubObject("Open(const QString&, bool)", inFile1, true);
    QAxObject* shapes = document->querySubObject("InlineShapes");
    QAxObject* chart = shapes->querySubObject("AddChart(int)", 74, 100, 100, 500, 800);
    document->dynamicCall("SaveAs(const QString&)", outFile);
    document->dynamicCall("Close()");
    axObject.dynamicCall("Quit()");
    @

    Thanks in advance


Log in to reply