Results 1 to 4 of 4

Thread: Creating new sheets in csv file

  1. #1
    Join Date
    Oct 2014
    Posts
    71
    Thanks
    13
    Qt products
    Qt5
    Platforms
    Windows

    Question Creating new sheets in csv file

    I am trying to write a data in csv file as below

    Qt Code:
    1. QFile file("Book.csv");
    2. QTextStream out(&file);
    3. l<<"StatusFrame1"<<"PORstat"<<"name";
    4. if(file.open(QIODevice::WriteOnly))
    5. {
    6.  
    7. out<<l.at(0).toStdString().c_str()<<","<<l.at(1).toStdString().c_str()<<"\n";
    8. out<<l.at(0).toStdString().c_str()<<","<<l.at(1).toStdString().c_str()<<"\n";
    9. }
    10.  
    11.  
    12. file.close();
    To copy to clipboard, switch view to plain text mode 
    The above code create a csv file(with one sheet) and successfully write the data on that sheet
    But I want one more new sheet to be created or added in same csv file(like how we have number of sheets in one excel file)
    So please let me know how can I create two or more sheets in one csv file.

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,316
    Thanks
    314
    Thanked 870 Times in 857 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Creating new sheets in csv file

    A CSV file is a flat ASCII file. There is no concept of "sheets" in such a file. You are obviously confused because Excel can export a single page of a workbook to a CSV format file, but once it is in that format there is no connection between that and a "Sheet" as defined by Excel. It's an ASCII file, and that's all it is.

  3. #3
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Creating new sheets in csv file

    Quote Originally Posted by d_stranz View Post
    A CSV file is a flat ASCII file. There is no concept of "sheets" in such a file.
    Exactly.

    However, if Excel can interpret some form of markup in such files to import different sections into different sheets, then this might still work.
    But then this would have to be asked for on an Excel forum, since it is Excel specific.

    Though it could be easily tested by having Excel export to CSV and import into a new document. If the sheets are still separated, then the file should contain the necessary markup, if they are not, then Excel can't do that.

    Cheers,
    _

  4. The following user says thank you to anda_skoa for this useful post:

    anh5kor (21st December 2015)

  5. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,316
    Thanks
    314
    Thanked 870 Times in 857 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Creating new sheets in csv file

    I have not seen any way in Excel to export more than a single sheet to any ASCII format, and indeed, the CSV files created contain only the printable contents of the cells in the exported sheet, nothing more (like meta-information on the workbook, sheets, etc.)

  6. The following user says thank you to d_stranz for this useful post:

    anh5kor (21st December 2015)

Similar Threads

  1. Creating xml file from Xml Schema (xsd) file
    By pieczara in forum Newbie
    Replies: 1
    Last Post: 25th February 2011, 23:11
  2. creating Xml file using QT
    By rk0747 in forum Qt Programming
    Replies: 3
    Last Post: 30th January 2010, 11:16
  3. Creating xls File
    By bismitapadhy in forum Qt Programming
    Replies: 0
    Last Post: 26th May 2009, 11:35
  4. Creating new XML file
    By Pembar in forum Qt Programming
    Replies: 3
    Last Post: 16th May 2009, 08:06
  5. creating .cfg file in qt
    By vishal.chauhan in forum Qt Programming
    Replies: 1
    Last Post: 11th January 2007, 10:26

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.