Results 1 to 3 of 3

Thread: Opening a MS Excel file to view from Qt Application

  1. #1
    Join Date
    Nov 2010
    Posts
    100
    Thanks
    38
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4

    Default Opening a MS Excel file to view from Qt Application

    Hello every one.. I am working on a Qt application where i write some data to a Excel file , now i have given a option in Toolbar to view the excel file to which i have written data into. I tried many things looking at the forums but it din help the excel file does not open.

    i did the following but does't open up a Excel.

    Qt Code:
    1. QProcess *process = new QProcess(this);
    2. QString program = "msexcel.exe";
    3. QString folder = "E:/DataReceiver Excel Log/Mon 20-06-2011, 09.01.xls";
    4. process->start(program, QStringList() << folder);
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. QString folder = "E:/DataReceiver Excel Log/Mon 20-06-2011, 09.01.xls";
    2. process->start(newfilename, QStringList() << "");
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. QDesktopServices::openUrl(QUrl(tr(newfilename)));
    2. if(!QDesktopServices::openUrl(url)) {
    3. excelview.load(url);
    4. excelview.showMaximized();
    5. }
    To copy to clipboard, switch view to plain text mode 

    none of the three above methods worked.. What is it wrong that i am doing. ?

    Thank you

  2. #2
    Join Date
    Nov 2010
    Posts
    100
    Thanks
    38
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4

    Default Re: Opening a MS Excel file to view from Qt Application

    hello some one knows what i might be doing wrong here. ? Not able to figure out whats wrong .

    thank you

  3. #3
    Join Date
    Dec 2008
    Location
    Poland
    Posts
    383
    Thanks
    52
    Thanked 42 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Opening a MS Excel file to view from Qt Application

    1st snippet:
    error in program path
    Qt Code:
    1. QString program = "msexcel.exe";
    To copy to clipboard, switch view to plain text mode 
    that's mean msexcel.exe is located either in Your program directory or within Path windows variable. Use full path i.e "c:/path/to/excel.exe"

    3rd snippet:
    error in
    Qt Code:
    1. QDesktopServices::openUrl(QUrl(tr(newfilename)));
    To copy to clipboard, switch view to plain text mode 
    should be:
    Qt Code:
    1. QDesktopServices::openUrl(QUrl(tr(newfilename.toAscii())));
    To copy to clipboard, switch view to plain text mode 
    don't use tr() (it's function for string translation into other languages, i.e english->polish, and file path is international as it is )

    try:
    Qt Code:
    1. QString newfilename = "C:/path/to/file.xls";
    2. QDesktopServices::openUrl(QUrl(newfilename.prepend( "file:///" )));
    To copy to clipboard, switch view to plain text mode 
    In the near future - corporate networks reach out to the stars. Electrons and light flow throughout the universe.
    The advance of computerization however, has not yet wiped out nations and ethnic groups.

Similar Threads

  1. Run application by opening file
    By rivci in forum Qt Programming
    Replies: 3
    Last Post: 2nd March 2011, 07:54
  2. Formatting Excel File
    By bismitapadhy in forum Qt Programming
    Replies: 2
    Last Post: 27th May 2009, 11:16
  3. How to read Excel file with Qt
    By HelloDan in forum Qt Programming
    Replies: 3
    Last Post: 13th May 2009, 20:27
  4. Read \Write Excel File using Qt
    By xingshaoyong in forum Qt Programming
    Replies: 4
    Last Post: 27th July 2007, 22:07
  5. Opening pdf file in Qt application
    By jyoti kumar in forum Qt Programming
    Replies: 2
    Last Post: 20th June 2007, 18:35

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.