qt写入excel 基本的操作,
QString fileName = QFileDialog::getSaveFileName(NULL,"Save File",".","Excel File (*.xls)");
fileName.replace("/","\\"); //这一步很重要,c:/123.xls保存失败,c:\123.xls保存成功!
QAxWidget _excel("Excel.Application");
_excel.setProperty("Visible",false);
QAxObject * _workbooks = _excel.querySubObject("WorkBooks");
_workbooks->dynamicCall("Add"); //添加一个新的工作薄
QAxObject * _workbook = _excel.querySubObject("ActiveWorkBook");
_workbook->dynamicCall("SaveAs (const QString&)",fileName); //保存
_workbook->dynamicCall("Close (Boolean)", false);
_excel.dynamicCall("Quit (void)");
1