I save data from two vectors to a .csv file in this way (vectors are of type double):

void MainWindow::save_csv() { QString filename = QFileDialog::getSaveFileName(this, tr("Save csv"), ".", tr("csv files (*.csv)")); QFile file(filename); if (file.open(QFile::WriteOnly|QFile::Truncate)) { QTextStream stream(&file); for(int i=0;i<=for_step_x.size();i++)// для звездной величины { stream << for_step_x[i]<<"\t"<<","<<for_step_y[i]<<"\n"; } file.close(); } QMessageBox::information(NULL,"show","Данные успешно сохранены"); } 

When opening with a Word, the elements of the lines are written as they should be (through a tabulation with a comma). When opened with Excel, all data is written in one column. Tried and without tabulation, having made a separator only ",", the excel also recognizes as one column. How to fix it?

  • try to separate columns only ';' (semicolon) - gil9red
  • @ gil9red no, it doesn't work either. can try to translate elements of vectors into a string? although it should work like that - bronstein87
  • @ bronstein87, and if you manually create a csv file, distribute numbers there separated by commas, and then try to open them in Excel? You never know ... Well, as an even nonsense, the installation of the encoding and the flag QFile::Text add. Whether too little ... - alexis031182

0