Results 1 to 2 of 2

Thread: QAxWidget embed excel into QDialog

  1. #1
    Join Date
    Oct 2009
    Posts
    65
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QAxWidget embed excel into QDialog

    Hello everybody,
    I started to read similar posts and I try to apply it but without success.
    I need to open an excel file (that contains macro and use an INI file) into my application, embedding it into it.
    I design a widget, and I promoted it to QAxWidget, after that I create this code to use the file:
    Qt Code:
    1. ui->excel->setControl(srcfile);
    2.  
    3. //QAxObject * workbooks = ui->excel->querySubObject("WorkBooks");
    4. //workbooks->dynamicCall("Open (const QString&)", srcfile);
    5. //QAxObject * workbook = workbooks->querySubObject("ActiveWorkBook");
    6.  
    7. QAxObject * worksheet = ui->excel->querySubObject("Worksheets(1)");
    8. QAxObject * piva, * tipo, * data, * num, * scad, * tot;
    9.  
    10. //ui->excel->setProperty("Visible", false);
    11.  
    12. int i=0;
    13. while (qry->next()){
    14.  
    15. piva = worksheet->querySubObject("Cells(int,int)", i+2,1);
    16. tipo = worksheet->querySubObject("Cells(int,int)", i+2,3);
    17. data = worksheet->querySubObject("Cells(int,int)", i+2,4);
    18. num = worksheet->querySubObject("Cells(int,int)", i+2,5);
    19. scad = worksheet->querySubObject("Cells(int,int)", i+2,6);
    20. tot = worksheet->querySubObject("Cells(int,int)", i+2,7);
    21.  
    22.  
    23. piva->setProperty("Value",qry->value(0).toString().mid(2,-1).trimmed());
    24. if (qry->value(2).toString().startsWith('N'))
    25. tipo->setProperty("Value","N");
    26.  
    27. QDate dtData,dtScad;
    28. dtData=QDate::fromString(qry->value(1).toString(),"yyyyMMdd");
    29. dtScad=QDate::fromString(qry->value(4).toString(),"yyyyMMdd");
    30.  
    31. data->setProperty("Value",dtData.toString("dd/MM/yy"));
    32. //num->setProperty("Value",QString("%1 %2").arg(qry->value(2).toString()).arg(qry->value(3).toString()));
    33. num->setProperty("Value",qry->value(3).toString());
    34. scad->setProperty("Value",dtScad.toString("dd/MM/yy"));
    35.  
    36. tot->setProperty("Value",qry->value(5).toDouble());
    37.  
    38. i++;
    39.  
    40. }
    41.  
    42. ui->excel->setProperty("DisplayAlerts", false);
    43. ui->excel->dynamicCall("Run(QVariant)", "ckCampi");
    To copy to clipboard, switch view to plain text mode 

    When I enter the while I got Segmentation Fault error, and my application say QAxBase::dynamicCallHelper: Object does not support automation.

    Where is the mistake?

    I've also verified that If I run Macro that use INI file that not respond, as if the file was moved, the file is loaded in any qt system path? Which one? The ini file is correctly configured and positioned into the same path of excel file (as it should be!).

    Have you got any ideas?

    Thanks a lot for your time

    Michele

  2. #2
    Join Date
    Oct 2009
    Posts
    65
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QAxWidget embed excel into QDialog

    I've got other test and we have two scenarios:
    1) If I use QAxWidget->setControl("C:\file.xls") I see the sheet into my control (as I like) but... I can't fill its cells programmaticaly: the querySubObject() and dynamicCall() aren't available in this configuration and raise segmentation fault error.
    2) If I use QAxWidget->setControl("Excel.Application") I can work programmatically on my excel file, but... the file won't embedded into my QAxWidget that it remain white.

    So, how can Got the 1.5 possibility ? How programmatically change a file embedded by setControl()?

    Thanks a lot for your time

    Michele

    PS. I've opensource version of QT

Similar Threads

  1. How to embed a QAxWidget into QGraphicsProxyWidget?
    By Junan in forum Qt Programming
    Replies: 1
    Last Post: 23rd August 2013, 18:07
  2. Replies: 10
    Last Post: 11th June 2012, 10:16
  3. Replies: 9
    Last Post: 25th March 2011, 22:22
  4. QDialog.exec() exiting without calling QDialog::accept()
    By doggrant in forum Qt Programming
    Replies: 3
    Last Post: 2nd February 2011, 12:35
  5. QAxWidget
    By chak_med in forum Newbie
    Replies: 1
    Last Post: 10th September 2006, 21:05

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.