Results 1 to 6 of 6

Thread: Where is documentation for excel manipulating commands?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2010
    Posts
    86
    Thanks
    17
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Where is documentation for excel manipulating commands?

    For example, the following gives you the object of active sheet:
    QAxObject *excelWorkSheet = pexcel->querySubObject("ActiveSheet");

    But, where can I find the list of commands that I can give to excel objects?
    I tried to find Excel COM docs, but they were for VB and totally confusing.
    My aim is to create a chart from a table.
    Qt Code:
    1. QAxObject* excel = new QAxObject("Excel.Application", 0);
    2. if (!excel)
    3. {
    4. QMessageBox::critical(this,
    5. "Error while creating excel object!",
    6. "No excel object can be instantiated!\n"
    7. "Please, check if you have MS Excel installed.");
    8. log("Excel object cannot be created (is not Excel installed?)!", 1);
    9. return;
    10. }
    11. //QAxObject* application = excel->querySubObject("Application()");
    12. QAxObject* workbooks = excel->querySubObject("Workbooks()");
    13. if (!workbooks)
    14. {
    15. QMessageBox::critical(this,
    16. "Error while creating excel object!",
    17. "No excel object can be instantiated!\n"
    18. "Workbooks in Excel document can be found.");
    19. log("Excel object cannot be created (is not Excel installed?)!", 1);
    20. return;
    21. }
    22. QAxObject* workbook = workbooks->querySubObject("Add()");
    23. QAxObject* worksheet = workbook->querySubObject("Worksheets(int)", 1 );
    24. ChartView* active = activeMdiChild();
    25. if (!active)
    26. {
    27. log("There is no activated chart window!", 1);
    28. return;
    29. }
    30. QStandardItemModel *model = active->getModel();
    31. if (!model)
    32. {
    33. log("There is no data in chart window!", 1);
    34. return;
    35. }
    36. for (int x=1; x<model->columnCount()+1; x++)
    37. {
    38. QAxObject *range = worksheet->querySubObject("Range(QString)",
    39. getExcelColumnName(x) + "1" +
    40. ":" +
    41. getExcelColumnName(x) + "1"
    42. );
    43. range->setProperty("Value", model->horizontalHeaderItem(x-1)->text());
    44. delete range;
    45. }
    46. for (int y=1; y<model->rowCount()+1; y++)
    47. for (int x=1; x<model->columnCount()+1; x++)
    48. {
    49. QAxObject *range = worksheet->querySubObject("Range(QString)",
    50. getExcelColumnName(x) + QString("%1").arg(y+1) +
    51. ":" +
    52. getExcelColumnName(x) + QString("%1").arg(y+1)
    53. );
    54. range->setProperty("Value", model->item(y-1, x-1)->data(Qt::EditRole));
    55. delete range;
    56. }
    To copy to clipboard, switch view to plain text mode 
    QAxObject *chart = worksheet->querySubObject("ChartObjects.Add(int, int, int, int)", 200,200,200,200);

    Qt Code:
    1. workbook->dynamicCall("SaveAs (const QString&)", fileName);
    2. workbook->dynamicCall("Close()");
    3. excel->dynamicCall("Quit()");
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    May 2010
    Posts
    86
    Thanks
    17
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Where is documentation for excel manipulating commands?

    I have found some Object Model manual on the site of MS, but it is quite hard to find out the use cases in Qt...
    http://office.microsoft.com/en-us/ex...080550097.aspx

  3. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Where is documentation for excel manipulating commands?

    At a guess* this:
    Qt Code:
    1. QAxObject *chart = worksheet->querySubObject("ChartObjects.Add(int, int, int, int)", 200,200,200,200);
    To copy to clipboard, switch view to plain text mode 
    should be this:
    Qt Code:
    1. QAxObject *charts = worksheet->querySubObject("ChartObjects");
    2. QAxObject *newChart = charts->dynamicCall("Add(int, int, int, int)", 200,200,200,200);
    To copy to clipboard, switch view to plain text mode 

    I have used dumpcpp (it's in the docs) to get a more natural set of C++ proxy classes for the ActiveX objects. Never done it with Excel though.

    * I mean it.

  4. The following user says thank you to ChrisW67 for this useful post:

    falconium (25th April 2011)

Similar Threads

  1. Manipulating member name to be controlled by string
    By jwflammer in forum Qt Programming
    Replies: 3
    Last Post: 28th February 2011, 02:19
  2. manipulating qmainwindow widget through qdialog
    By xeroblast in forum Qt Programming
    Replies: 1
    Last Post: 16th December 2010, 07:17
  3. Manipulating excel files in Qt?
    By icttrack in forum Qt Programming
    Replies: 3
    Last Post: 24th July 2010, 11:44
  4. Replies: 1
    Last Post: 7th July 2007, 08:41
  5. Adding Qt's documentation to Xcode documentation browser
    By fabietto in forum Qt Programming
    Replies: 0
    Last Post: 10th June 2007, 15:38

Tags for this Thread

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
  •  
Qt is a trademark of The Qt Company.