1. CSV files do not support multiple worksheets in Excel mode. A CVS file can only be converted to EXCEL one worksheet.
2. Comma-separated values (comma-separated values,csv, sometimes referred to as character-delimited values, because delimited characters can also be not commas), whose files store tabular data (numbers and text) in plain text. Plain text means that the file is a sequence of characters,
Does not contain data that must be interpreted like a binary number. A CSV file consists of any number of records separated by a newline character, each record consists of a field, and the delimiter between the fields is another character or string, most commonly a comma or tab. Usually
All records have exactly the same field sequence.
Qt TableView Export CSV
1 ///2 voidExporttocsv (qabstractitemmodel*view, QString fileName)3 {4 if(Filename.isempty ())5 return;6 7 QFile file (fileName);8 9 if(File.Open (qiodevice::writeonly))Ten { OneQtextstream Stream (&file); A intCc=view->ColumnCount (); - - qstringlist list; the for(intI=0; i<cc;i++) - { -list<< view->Headerdata (i,qt::horizontal,qt::D isplayrole). toString (); - } +stream<< List.join (",") <<"\ r \ n"; - + A for(intI=0; I<view->rowcount (); i++) at { - list.clear (); - for(intj=0; j<cc;j++) - { -List<<view->index (I,J). Data (). toString (); - } instream<< List.join (",") <<"\ r \ n"; - } to file.close (); + } - } the among them: *View=ui.tableview->model ();
QT Generate CSV file