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. CSV format!
Qt 6.11 is out! See what's new in the release blog

CSV format!

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 2.6k Views 1 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.
  • K Offline
    K Offline
    KillGabio
    wrote on last edited by
    #1

    Hi developers..
    i have the following code
    @void ExportData::on_exportar_clicked()
    {
    if (this->ui->table_agregados->rowCount () != 0){
    this->habilitar_botones (false);
    Dialogcheckeo * get_file_path = new Dialogcheckeo (this, 3);
    connect (get_file_path, SIGNAL(enviar_texto(QString)), this, SLOT (recibir_texto (QString)));
    get_file_path->exec ();
    QFile remito (QDir::homePath ()+"/Escritorio/"+filename+".csv");
    int progress= 0;
    double avance = 100/ this->ui->table_agregados->rowCount ();
    if (remito.open (QFile::WriteOnly | QFile::Truncate)){
    QTextStream data( &remito );
    QStringList strList;
    for (int row = 0; row < this->ui->table_agregados->rowCount (); row++){
    for (int col = 0; col < this->ui->table_agregados->columnCount (); col++){
    strList << this->ui->table_agregados->item (row, col)->text ();
    }
    data << strList.join (",")+"\n";
    strList.clear ();
    progress+= avance;
    this->ui->progressBar->setValue (progress);
    }
    }else remito.errorString ();
    this->ui->progressBar->setValue (100);
    remito.close ();
    this->habilitar_botones(true);
    }
    }@

    i can open this file with Excel and Open but what i want is to set the columns name and width (maybe change the font also if its possible lol) how can i accomplish that with Qt? how should i store that information?

    I`ve seen something like this:

    Col1, col 2, col 3
    data1, data2, data3
    data4, data5, data6

    but this doesnt work, cols are inserted as cell`s not as column names :(

    i just need to know the format of csv so that i can play with that, not just simple values separated by a comma

    hope anyone can help me...thanks a lot!

    1 Reply Last reply
    0
    • G Offline
      G Offline
      GentooXativa
      wrote on last edited by
      #2

      The CSV standard is only with separators (, or ;) you cant define a style inside.

      http://en.wikipedia.org/wiki/Comma-separated_values

      Jose Vicente Giner Sanchez - Senior Mobile Developer

      www.gigigo.com

      C/ Dr. Zamenhof 36bis, 1ºA 28027 Madrid
      T: +34 917431436

      1 Reply Last reply
      0
      • A Offline
        A Offline
        andre
        wrote on last edited by
        #3

        If you are looking for a more complex format for spreadsheets, take a look at the ODS format (open document standard for spreadsheet). It is a zipped XML format. Qt does not have a build-in way to generate them using high-level primitives, but you should be able to create it using XML and then zipping that XML.

        1 Reply Last reply
        0
        • K Offline
          K Offline
          KillGabio
          wrote on last edited by
          #4

          will do, thanks both of you guys!

          Greetings!

          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