Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. International
  3. Spanish
  4. Cómo Leer/Escribir de una hoja de Excel?
Qt 6.11 is out! See what's new in the release blog

Cómo Leer/Escribir de una hoja de Excel?

Scheduled Pinned Locked Moved Solved Spanish
2 Posts 1 Posters 1.7k Views
  • 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.
  • E Offline
    E Offline
    Eduardo12l
    wrote on last edited by Eduardo12l
    #1

    Quiero leer una hoja de Excel como si fuera una hoja de una Database del tipo SQL. He tratado de leer la documentación (http://wiki.qt.io/Handling_Microsoft_Excel_file_format) y parece que la opción más sencilla y confiable es usar ActiveX sin embargo, tengo entendido que para obtener la librería debo pagar y yo tengo actualmente la versión gratuita.

    Por otro lado, esta el método QODBC el cual parece que se conecta de manera similar al QMYSQL y al QSQLITE, sin embargo, en el Link dice que puede haber bug y parece que suceden problemas cuando hay datos de diferentes tipos(ejemplo INT y QString ).

    1 Reply Last reply
    0
    • E Offline
      E Offline
      Eduardo12l
      wrote on last edited by
      #2

      Ya tengo la solucion

      QAxObject* excel     = new QAxObject("Excel.Application");
      QAxObject* workbooks = excel->querySubObject("Workbooks");
      QAxObject* workbook  = workbooks->querySubObject("Open(const QString&)","c:\\temp\\i1.xlsx");
      QAxObject* sheets    = workbook->querySubObject("Worksheets");
      QAxObject* sheet     = sheets->querySubObject("Item(int)", 1);
      excel->dynamicCall("ScreenUpdating()", false);
      i = 0;
      for (int f = 2; f <= 740; ++f){
          p = 0;
          for(int c = 2; c <= 11; ++c){
              auto cCell = sheet->querySubObject("Cells(int,int)",f,c);
              if(cCell->dynamicCall("Value()").value<int>() == NULL){
                 if(c == 2){
                    a = cCell->dynamicCall("Value()").toString();
                    p = p + 1;
                 }else if(c == 4){
                    d = cCell->dynamicCall("Value()").toString();
                    p = p + 1;
                 }
              }
          }
      
      1 Reply Last reply
      0

      • Login

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