Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Merge Excel Cell using QAxObject

Merge Excel Cell using QAxObject

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 528 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    npatil15
    wrote on last edited by
    #1

    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 :)

    Gojir4G 1 Reply Last reply
    0
    • N npatil15

      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 :)

      Gojir4G Offline
      Gojir4G Offline
      Gojir4
      wrote on last edited by Gojir4
      #2
      This post is deleted!
      1 Reply Last reply
      0
      • N Offline
        N Offline
        npatil15
        wrote on last edited by
        #3

        For me its crashing for this:

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

        Where it works for some lesser number of coloum.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved