View Full Version : Opening a MS Excel file to view from Qt Application

20th June 2011, 04:41
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.

QProcess *process = new QProcess(this);
QString program = "msexcel.exe";
QString folder = "E:/DataReceiver Excel Log/Mon 20-06-2011, 09.01.xls";
process->start(program, QStringList() << folder);

QString folder = "E:/DataReceiver Excel Log/Mon 20-06-2011, 09.01.xls";
process->start(newfilename, QStringList() << "");

if(!QDesktopServices::openUrl(url)) {

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

Thank you

20th June 2011, 07:51
hello some one knows what i might be doing wrong here. ? Not able to figure out whats wrong .

thank you

20th June 2011, 08:18
1st snippet:
error in program path

QString program = "msexcel.exe";
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

should be:

QDesktopServices::openUrl(QUrl(tr(newfilename.toAs cii())));
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 :) )


QString newfilename = "C:/path/to/file.xls";
QDesktopServices::openUrl(QUrl(newfilename.prepend ( "file:///" )));