Results 1 to 3 of 3

Thread: Open excel file on buttonclick

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

    Question Open excel file on buttonclick

    I am trying to open a pdf and a excel file on button click.
    Qt Code:
    1. connect(ui->button1,SIGNAL(clicked()),this,SLOT(OpenPdfFile()));
    2. void MainWindow::OpenPdfFile()
    3. {
    4. QDesktopServices::openUrl(QUrl("GMHeaderCheckTool_UserManual.pdf", QUrl::TolerantMode));//working perfectly
    5.  
    6. }
    7. connect(ui->button2,SIGNAL(clicked()),this,SLOT(OpenExcelFile()));
    8. void MainWindow::OpenExcelFile()
    9. {
    10. // where ExcelFileName conatin the Path of the excel location
    11. QString ExcelFileName = "d:/Tools/HeadercheckTool/Requirment/To Anil/To Anil/Tool.xlsx"
    12. QDesktopServices::openUrl(QUrl(ExcelFileName, QUrl::TolerantMode));//Not working
    13. }
    To copy to clipboard, switch view to plain text mode 
    When I am trying to open the Excel file I am getting the below error
    d:/Tools/HeadercheckTool/Requirment/To Anil/To Anil/Tool.xlsx' failed (error 2)
    Please let me know how can i open excel file?

  2. #2
    Join Date
    Jul 2008
    Location
    Germany
    Posts
    503
    Thanks
    11
    Thanked 76 Times in 74 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Open excel file on buttonclick

    Hi, try to add file:/// in front of the path. Maybe you also need to add " to your string because of the spaces in the path.

    Best regards,

    Ginsengelf

  3. #3
    Join Date
    Oct 2009
    Posts
    483
    Thanked 97 Times in 94 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Open excel file on buttonclick

    Use QUrl::fromLocalFile().

Similar Threads

  1. Replies: 1
    Last Post: 30th June 2011, 00:32
  2. Open Microsoft excel files in QT --linux
    By qixier in forum Qt Programming
    Replies: 1
    Last Post: 2nd June 2010, 10:58
  3. Open Ms Word, Ms excel, ppt files in QT -Linux
    By amankamboj1 in forum Qt Programming
    Replies: 3
    Last Post: 5th September 2009, 09:55
  4. Formatting Excel File
    By bismitapadhy in forum Qt Programming
    Replies: 2
    Last Post: 27th May 2009, 12:16

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.