QT Generate CSV file

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.