核心代码:
QAxObject* excel = new QAxObject("Excel.Application");
excel->setProperty("Visible", false);
QAxObject* workbooks = excel->querySubObject("WorkBooks");
workbooks->dynamicCall("Open (const QString&)", QString("c:\\副本1.xls")); //filename
QAxObject* workbook = excel->querySubObject("ActiveWorkBook");
QAxObject* worksheets = workbook->querySubObject("WorkSheets");
QAxObject* worksheet = workbook->querySubObject("Worksheets(int)", 1); //worksheet number
QAxObject* usedrange = worksheet->querySubObject("UsedRange");
QAxObject* rows = usedrange->querySubObject("Rows");
QAxObject* columns = usedrange->querySubObject("Columns");
int intRowStart = usedrange->property("Row").toInt();
int intColStart = usedrange->property("Column").toInt();
int intCols = columns->property("Count").toInt();
int intRows = rows->property("Count").toInt();
QAxObject * cell;
for (int i = intRowStart; i < intRowStart + intRows; i++)
{
for (int j = intColStart; j < intColStart + intCols; j++)
{
cell = excel->querySubObject("Cells(Int, Int)", i, j );
QVariant cellValue