".", tr("Microsoft Office 2003 (*.xls)"));//获取保存路径
if (fileName.isEmpty()) {
QMessageBox::critical(0, tr("错误"), tr("要保存的文件名为空!"));
return;
}
//建立Excel对象
QAxObject *excel = new QAxObject("Excel.Application");
excel->dynamicCall("SetVisible(bool)", true); //如果为了看自己的程序到底怎样工作,可以设置为true
excel->setProperty("Visible", false);
QAxObject *workbooks = excel->querySubObject("WorkBooks");
workbooks->dynamicCall("Add");
QAxObject *workbook = excel->querySubObject("ActiveWorkBook");
QAxObject *worksheet = workbook->querySubObject("Worksheets(int)", 1);
column);//row column为要插入的行和列
fileName));
QMessageBox::information(this, tr("OK"), tr("保存成功!"));
workbook->dynamicCall("Close()");
worksheet->clear();//释放所有工作表
excel->dynamicCall("Quit()");
delete excel;//释放excel