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. QAxObject writing cell more than column 16600 crashing application
Qt 6.11 is out! See what's new in the release blog

QAxObject writing cell more than column 16600 crashing application

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 448 Views
  • 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 aha_1980
    #1

    Hello,

    It's too wired working of QAxObject,
    Whenever I tried to access cell more 16600 its crashing the application, where writing between this range working fine.

    I have debug it writing directly like this:

      QAxObject* excel = new QAxObject( "Excel.Application", 0);
      excel->setProperty( "DisplayAlerts", 0);
    
      excel->dynamicCall("SetScreenUpdating(bool)", false);
      excel->dynamicCall("SetDisplayAlerts(bool)", false);
    
      QAxObject* workbooks = excel->querySubObject( "Workbooks" );
      workbooks->querySubObject( "Open(const QString&)", filepath);
    
      QAxObject* workbook = excel->querySubObject("ActiveWorkBook");
    
      QAxObject* sheets = workbook->querySubObject( "Worksheets" );
    
    QAxObject* sheet = sheets->querySubObject("Item(int)", count);
    
    sheet->querySubObject("Cells(int,int)", 10, 16600)->setProperty("Value", QString("SomeData"));
    
    

    As soon is hit this last statement, the application crashes.

    Can someone please help me what I'm missing here ?

    Thanks :)

    JonBJ 1 Reply Last reply
    0
    • N npatil15

      Hello,

      It's too wired working of QAxObject,
      Whenever I tried to access cell more 16600 its crashing the application, where writing between this range working fine.

      I have debug it writing directly like this:

        QAxObject* excel = new QAxObject( "Excel.Application", 0);
        excel->setProperty( "DisplayAlerts", 0);
      
        excel->dynamicCall("SetScreenUpdating(bool)", false);
        excel->dynamicCall("SetDisplayAlerts(bool)", false);
      
        QAxObject* workbooks = excel->querySubObject( "Workbooks" );
        workbooks->querySubObject( "Open(const QString&)", filepath);
      
        QAxObject* workbook = excel->querySubObject("ActiveWorkBook");
      
        QAxObject* sheets = workbook->querySubObject( "Worksheets" );
      
      QAxObject* sheet = sheets->querySubObject("Item(int)", count);
      
      sheet->querySubObject("Cells(int,int)", 10, 16600)->setProperty("Value", QString("SomeData"));
      
      

      As soon is hit this last statement, the application crashes.

      Can someone please help me what I'm missing here ?

      Thanks :)

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @npatil15
      So presumably it's crashing because you don't test the result of sheet->querySubObject("Cells(int,int)", 10, 16600), which maybe is returning nullptr?

      And if 16,600 is number of columns in your code (would help if you said), have you looked the limits of your Excel? E.g. I can't vouch for it, but https://answers.microsoft.com/en-us/msoffice/forum/all/what-is-the-maximum-number-of-columns-in-a/5a053135-4865-e011-8dfc-68b599b31bf5

      in an Excel 2007-2010 format worksheet (in a .xlsx, .xlsm or .xlsb workbook) 16.384 columns (A ... XFD).

      Quite why you want 16k columns I can't imagine....

      1 Reply Last reply
      3
      • N Offline
        N Offline
        npatil15
        wrote on last edited by
        #3

        You were right, I'm accessing large range for coloum which is somewhere wrong because of my uninitialized variable mistakenly.

        But thank you so much, I was unaware of this key knowledge of excel max limits.

        Thanks :)

        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