Results 1 to 4 of 4

Thread: QAxObject probelm for Write the Excel

  1. #1
    Join Date
    Oct 2014
    Posts
    71
    Thanks
    13
    Qt products
    Qt5
    Platforms
    Windows

    Question Re: QAxObject probelm for Write the Excel

    I want to write the content to excel sheet.
    I saw one thread in Qt about Read and Write Excel.

    http://www.qtcentre.org/threads/8288...ite-Excel-File

    That described Excel reading via QAxObject.
    But when I #include <QAxObject> in my Qt code.My compiler complain "No such file and directory.

    So I am not able to write the code given below
    Qt Code:
    1. QAxObject* excel = new QAxObject( "Excel.Application", 0 );
    2. QAxObject* workbooks = excel->querySubObject( "Workbooks" );
    3. QAxObject* workbook = workbooks->querySubObject( "Open(const QString&)", exchange->getFilename() );
    4. QAxObject* sheets = workbook->querySubObject( "Worksheets" );
    To copy to clipboard, switch view to plain text mode 
    Please let me know how can I read and write an excel by using the above method or any other method.


    Added after 47 minutes:


    The above Query is solved.I have added the below two line.
    "CONFIG += qaxcontainer" to pro file and added
    #include <ActiveQt/QAxObject> as header and my code is working fine.

    But I am getting problem in creating the Excel file.
    The code on the above link shows how to open a excel file already created.
    But I want that my code should create and save the excel to specific location.

    Please let me know how can I achieve the same.
    Last edited by anh5kor; 11th December 2015 at 14:44.

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    4,769
    Thanks
    262
    Thanked 773 Times in 763 Posts
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: QAxObject probelm for Write the Excel

    Please let me know how can I achieve the same.
    You need to look in the Excel SDK documentation or the Excel type library (tlb or tli) file. There is an "Add" method for the Workbooks object which will create a Workbook with an ActiveSheet instance. You can then probably use a Save or SaveAs method on the Workbook to save it to a file of your own choosing.

    No, I won't give you example code. Teach yourself to fish, don't expect people to put fish in front of you, ready to eat.

  3. #3
    Join Date
    Mar 2016
    Posts
    1
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded Qt Jambi
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QAxObject probelm for Write the Excel

    Hi,
    I am facing problem in passing filename to workbook->dynamiccall()
    i want to pass the filename i will get by using QFileDialog::getSaveFileName()

    it will not get file path if i will pass returned file name as QString
    please help

    thnks,
    sharayu

  4. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    4,769
    Thanks
    262
    Thanked 773 Times in 763 Posts
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: QAxObject probelm for Write the Excel

    Maybe if you told us what arguments "dynamiccall()" expects and what you are sending it would be easier to help you.

Similar Threads

  1. Read/Write with Excel in Qt
    By alizadeh91 in forum Qt Programming
    Replies: 6
    Last Post: 7th April 2015, 23:11
  2. QAxObject Importing Excel named ranges using MS Query
    By simonb in forum Qt Programming
    Replies: 0
    Last Post: 24th July 2012, 09:45
  3. Can't save excel file with QaxObject
    By Mirmilstein in forum Qt Programming
    Replies: 3
    Last Post: 2nd April 2012, 10:05
  4. How can I Read Write Excel File
    By xingshaoyong in forum Qt Programming
    Replies: 6
    Last Post: 13th July 2011, 21:16
  5. Read \Write Excel File using Qt
    By xingshaoyong in forum Qt Programming
    Replies: 4
    Last Post: 27th July 2007, 23:07

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.