Finally Solved.Luckily I found some posts told the reason----It seems the qt has to initialize and release OLE in a sub Thread(the GUI Thread has done this job so sometimes it may not show errors)
Here is the code:
#include <QCoreApplication>
#include <QAxObject>
#include "qt_windows.h" //Necessary
#include <QVariant>
#include <QDebug>
int main(int argc, char *argv[])
{
//Initialize OLE
HRESULT r = OleInitialize(0);
if (r != S_OK && r != S_FALSE)
{qWarning("OLE initialize failure(error %x)",(unsigned int)r);}
QCoreApplication a(argc, argv);
QAxObject excel("Excel.Application");
excel.setProperty("Visible",false);
QAxObject *workbooks = excel.querySubObject("WorkBooks");
workbooks->dynamicCall("Open (const QString&)",QString("d:/grade.xls"));
QAxObject *workbook = excel.querySubObject("ActiveWorkBook");
QAxObject *worksheets = workbook->querySubObject("WorkSheets");
QAxObject *worksheet=worksheets->querySubObject("Item(int)",1);
QAxObject *range;
QString strVal;
QAxObject *usedrange=worksheet->querySubObject("UsedRange");
int endrow=usedrange->querySubObject("Rows")->property("Count").toInt();
int endcolumn=usedrange->querySubObject("Columns")->property("Count").toInt();
for (int i=1;i<=endrow;i++){
for (int j=1;j<=endcolumn;j++){
range=worksheet->querySubObject("Cells(int,int)",i,j);
strVal=range->dynamicCall("Value2()").toString();
qDebug()<<strVal;
}
qDebug()<<endl;
}
workbook->dynamicCall("Close()");
excel.dynamicCall("Quit()");
OleUninitialize();
return a.exec();
}