Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Merge Excel Cell using QAxObject



  • Hello,

    I got successfull for merge cell in excel, but when coloum reaches to index more than 26(A-Z) then it doesn't work.

    void Excel::setCellMerage(QAxObject *sheet, int topLeftRow, int topLeftColumn, int bottomRightRow, int bottomRightColumn)
    {
        QString cell;
        cell.append(QChar(topLeftColumn - 1 + 'A'));
        cell.append(QString::number(topLeftRow));
        cell.append(":");
        cell.append(QChar(bottomRightColumn - 1 + 'A'));
        cell.append(QString::number(bottomRightRow));
    
        QAxObject *range = sheet->querySubObject("Range(const QString&)", cell);
        range->setProperty("VerticalAlignment", -4108);//xlCenter
        range->setProperty("WrapText", true);
        range->setProperty("MergeCells", true);
    
        delete range;
    }
    

    I know that the logic is made to work for range A-Z coloum only, but didnt understand how I obtain the logic to merge cell more than coloum index 26.

    Please suggest me something.

    Thanks :)



  • This post is deleted!


  • For me its crashing for this:

    setCellMerage(sheet, 10, 60, 10, 65);

    Where it works for some lesser number of coloum.


Log in to reply