Solved QAxObject writing cell more than column 16600 crashing application
-
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 :)
-
@npatil15
So presumably it's crashing because you don't test the result ofsheet->querySubObject("Cells(int,int)", 10, 16600)
, which maybe is returningnullptr
?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....
-
@npatil15
So presumably it's crashing because you don't test the result ofsheet->querySubObject("Cells(int,int)", 10, 16600)
, which maybe is returningnullptr
?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....
-
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 :)