QAxObject *range = StatSheet->querySubObject("Range(const QVariant&)", QVariant( QString("A1:C10"))); range = StatSheet->querySubObject( "Cells(const QVariant&,const QVariant&)",QVariant(2),QVariant(3)); range->dynamicCall("SetValue(const QVariant&)", ui->lineEdit_25->text()); range = StatSheet->querySubObject( "Cells(const QVariant&,const QVariant&)",QVariant(3),QVariant(3)); range->dynamicCall("SetValue(const QVariant&)", ui->lineEdit_26->text()); range = StatSheet->querySubObject( "Cells(const QVariant&,const QVariant&)",QVariant(4),QVariant(3)); range->dynamicCall("SetValue(const QVariant&)", ui->lineEdit_27->text()); excel->dynamicCall( "SetVisible(bool)", TRUE ); this->setCursor(Qt::ArrowCursor); delete excel [font="Courier New"]; //никак не пойму как "ему" объяснить, а то ругается... }
delete excel [font="Courier New"];
void Widget::exportToExcel(){ this->setCursor(Qt::WaitCursor); QAxObject *excel = new QAxObject("Excel.Application", this); QAxObject *workbooks = excel->querySubObject("Workbooks"); QAxObject *workbook = workbooks->querySubObject("Open(const QString&)", "tabl.xlsx" ); QAxObject *sheets = workbook->querySubObject("Sheets"); QAxObject *StatSheet = sheets->querySubObject("Item(const QVariant&)", QVariant("1") ); StatSheet->dynamicCall("Select()"); QAxObject *range = StatSheet->querySubObject("Range(const QVariant&)", QVariant( QString("A1:C10"))); range = StatSheet->querySubObject( "Cells(const QVariant&,const QVariant&)",QVariant(2),QVariant(3)); range->dynamicCall("SetValue(const QVariant&)", ui->lineEdit_25->text()); range = StatSheet->querySubObject( "Cells(const QVariant&,const QVariant&)",QVariant(3),QVariant(3)); range->dynamicCall("SetValue(const QVariant&)", ui->lineEdit_26->text()); range = StatSheet->querySubObject( "Cells(const QVariant&,const QVariant&)",QVariant(4),QVariant(3)); range->dynamicCall("SetValue(const QVariant&)", ui->lineEdit_27->text()); excel->dynamicCall( "SetVisible(bool)", TRUE ); this->setCursor(Qt::ArrowCursor); delete excel; }
excel->dynamicCall( "SetVisible(bool)", TRUE ); this->setCursor(Qt::ArrowCursor); [font="Courier New"]; delete excel[/font]; }
void Widget::exportToExcel(){ this->setCursor(Qt::WaitCursor); QAxObject::QAxObject (QString const&, QObject*); // но на этот раз выдает ошибку только на эту строчку типа (ожидание первичного выражения до "(" ";" "," "*") 4 ошибки QAxObject *excel = new QAxObject("Excel.Application", this); QAxObject *workbooks = excel->querySubObject("Workbooks"); QAxObject *workbook = workbooks->querySubObject("Open(const QString&)", "C:\Temp\tipaprogramy\tabl.xls" ); QAxObject *sheets = workbook->querySubObject("Sheets"); QAxObject *StatSheet = sheets->querySubObject("Item(const QVariant&)", QVariant("1") ); StatSheet->dynamicCall("Select()"); QAxObject *range = StatSheet->querySubObject("Range(const QVariant&)", QVariant( QString("A1:C10"))); range = StatSheet->querySubObject( "Cells(const QVariant&,const QVariant&)",QVariant(2),QVariant(3)); range->dynamicCall("SetValue(const QVariant&)", ui->lineEdit_25->text()); range = StatSheet->querySubObject( "Cells(const QVariant&,const QVariant&)",QVariant(3),QVariant(3)); range->dynamicCall("SetValue(const QVariant&)", ui->lineEdit_26->text()); range = StatSheet->querySubObject( "Cells(const QVariant&,const QVariant&)",QVariant(4),QVariant(3)); range->dynamicCall("SetValue(const QVariant&)", ui->lineEdit_27->text()); excel->dynamicCall( "SetVisible(bool)", TRUE ); this->setCursor(Qt::ArrowCursor); delete excel; }
C++ (Qt)[font="Courier New"]; delete excel[/font];