在使用QAxObject打开xlsx文件时,程序运行到语句:
QAxObject *work_books->dynamicCall("Open(const QString&)", strFile.toLocal8Bit());
时出现调试错误,如下:
QAxBase: Error calling IDispatch member Open: Exception thrown by server
Code : 1004
Source : Microsoft Excel
Description: ??????? test.xlsx????????????????
Help : xlmain11.chm
Connect to the exception(int,QString,QString,QString) signal to catch this exception
运行到下面的语句时:
QAxObject *first_sheet = work_sheets->querySubObject("Item(int)", 1);
first_sheet->dynamicCall("delete");
错误提示如:
QAxBase: Error calling IDispatch member delete: Exception thrown by server
Code : 1004
Source : Microsoft Excel
Description: ????????????????
????????????????????????????????????????????
Help : xlmain11.chm
Connect to the exception(int,QString,QString,QString) signal to catch this exception
但程序能运行,而且创建了文件,但使用下面的语句创建的文件名不对:
work_book->dynamicCall("Save()")
变量strFile = “test.xlsx”;
最终保存的文件名为:Sheet1.xlsx。
有人知道为什么?