Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QFile open Excel file
Forum Updated to NodeBB v4.3 + New Features

QFile open Excel file

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 4 Posters 4.3k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • JulianJ Offline
    JulianJ Offline
    Julian
    wrote on last edited by VRonin
    #1

    Hello people. How are you?

    A question. It's possible to open a microsoft exel's file with QFile?

    QString nombre;
        nombre=ui->lineEdit->text();
    
        file= new QFile(nombre);
        if (!file->open(QIODevice::ReadOnly | QIODevice::Text))
               {
               QMessageBox msg;
               msg.setText("The file is not open");
               msg.exec();
    
               qDebug()<<"the problem is :"<<file->error()<<endl;
        }
    

    And the return of qDebug() is 5. By the way the QString is the exel'name.

    jsulmJ 1 Reply Last reply
    0
    • EddyE Offline
      EddyE Offline
      Eddy
      wrote on last edited by
      #2

      Hi Julian,

      You will need the ActiveQt framework for that.

      Here is a good starting point : Using_ActiveX_Object_in_Qt

      Happy coding!

      Qt Certified Specialist
      www.edalsolutions.be

      1 Reply Last reply
      3
      • JulianJ Julian

        Hello people. How are you?

        A question. It's possible to open a microsoft exel's file with QFile?

        QString nombre;
            nombre=ui->lineEdit->text();
        
            file= new QFile(nombre);
            if (!file->open(QIODevice::ReadOnly | QIODevice::Text))
                   {
                   QMessageBox msg;
                   msg.setText("The file is not open");
                   msg.exec();
        
                   qDebug()<<"the problem is :"<<file->error()<<endl;
            }
        

        And the return of qDebug() is 5. By the way the QString is the exel'name.

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #3

        @Julian It is possible to open any file with QFile as long as your process has needed access rights. Use http://doc.qt.io/qt-5/qiodevice.html#errorString to get error text.
        But if you want to handle Excel documents then you will need to do what @Eddy suggested.

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        1
        • VRoninV Offline
          VRoninV Offline
          VRonin
          wrote on last edited by VRonin
          #4
          • I want my program to open MS Excel and load the file: QDesktopServices::openUrl(QUrl::fromUserInput(ui->lineEdit->text()));

          • I want to read/write an excel file with my application and I have MS Excel installed on my machine: https://forum.qt.io/topic/80167/qfile-and-fle-s-tipes/3

          • I want to read an excel file and I don't have MS Excel:

          QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
          db.setDatabaseName("DRIVER={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};DBQ=" + ui->lineEdit->text());
          
          • I want to read/write an excel file and I don't have MS Excel: https://github.com/VSRonin/QtXlsxWriter

          For more info: https://wiki.qt.io/Handling_Microsoft_Excel_file_format

          "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
          ~Napoleon Bonaparte

          On a crusade to banish setIndexWidget() from the holy land of Qt

          1 Reply Last reply
          4

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved