QAxObject *excel = new QAxObject(this); //连接Excel控件
excel->setControl("Excel.Application");
QAxObject *excel = new QAxObject(this); //连接Excel控件
excel->setControl("ket.Application");
QVariantList rowData = varRows[i].toList();
void Window::importExcelToDatabase()
{
QString strFilePathName = QFileDialog::getOpenFileName(this,QStringLiteral("选择Excel文件"),"",tr("Exel file(*.xls *.xlsx)"));
if(strFilePathName.isNull())
{
return ;
}
QAxObject *excel = new QAxObject(this); //连接Excel控件
if(excel->setControl("Excel.Application"))
{
excel->setControl("Excel.Application")
}
else
{
excel->setControl("ket.Application"); //连接Excel控件
}
excel->setProperty("Visible", false); //不显示窗体
QAxObject* workbooks = excel->querySubObject("WorkBooks"); //获取工作簿集合