i'm trying to import an excel file (that has only numbers like a matrix) into my Qtableview ! I found some code on the web that is related to QtableWidget but I ca figure it ou for QtableView thanks in advance
Try it with QAxObject - provides a QObject that wraps a COM objects: Like this:
QAxObject *excel = new QAxObject ("Excel.Application", 0);
//excel->dynamicCall ("SetVisible(bool)", true);
QAxObject *workbooks = excel->querySubObject ("Workbooks");
workbook = workbooks->querySubObject ("Open(const QString&)", fileName);
QAxObject *statSheet = sheets->querySubObject ("Item(const QVariant&)", QVariant (sheetsComboBox->currentText ()));
statSheet->dynamicCall ("Select()");
int column = 0;
int summe_column = 0;
int col = 1;
do
{
QAxObject* cell = statSheet->querySubObject ("Cells( int, int )", 1, col );
QVariant value = cell->dynamicCall( "Value()" );
QString string = statSheet->querySubObject ("Cells( int, int )", row, column)->dynamicCall( "Value()" ).toString();
++col;
}
while (col < 40)
}
you need also CONFIG += qaxcontainer in your .pro file.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.