CSV format!



  • 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!



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

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



  • 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.



  • will do, thanks both of you guys!

    Greetings!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.