Results 1 to 4 of 4

Thread: Best way to populate a QTableView or QTableWidget with Excel data

  1. #1
    Join Date
    Feb 2008
    Posts
    153
    Thanks
    40
    Thanked 8 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Post Best way to populate a QTableView or QTableWidget with Excel data

    Hi, I'm working on an application where I need to import Excel data and put it into either a QTableView or QTableWidget. I'm wondering what would be the best method to accomplish this:

    1. Export as XML document. I have no idea how to work with XML though.
    2. Export as a CSV (comma-seperated) or perhaps tab-seperated. I mostly have numbers in my data but there is a comma and some spaces occasionally. Would TAB-seperated work well, then?
    3. Or perhaps, is there a ready made solution?


    Thanks in advance.

    ~codeslicer

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Best way to populate a QTableView or QTableWidget with Excel data

    Quote Originally Posted by codeslicer View Post
    Export as XML document. I have no idea how to work with XML though.
    If you have no idea how to work with XML learn it or don't

    Export as a CSV (comma-seperated) or perhaps tab-seperated. I mostly have numbers in my data but there is a comma and some spaces occasionally. Would TAB-seperated work well, then?
    this is probably the best solution for you if you deal mainly with numbers. If you separate with ";" or "\t" does not matter.

    You can parse the csv into a table widget or you can use QxtCsvModel with a view. See here for more informations.

  3. The following user says thank you to Lykurg for this useful post:

    codeslicer (13th February 2010)

  4. #3
    Join Date
    Feb 2008
    Posts
    153
    Thanks
    40
    Thanked 8 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Best way to populate a QTableView or QTableWidget with Excel data

    Haha, forgot all about Qxt. I'll have to learn XML eventually, but for now I'll look into that.

    Thanks.

    ~codeslicer

  5. #4
    Join Date
    Feb 2011
    Location
    UK
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Best way to populate a QTableView or QTableWidget with Excel data

    I did it by using a perl module, Spreadsheet::ParseExcel which can be used to convert the xls file to a text file. Then used QT to read in the text file and format accordingly.

Similar Threads

  1. How to add data into the QTableWidget
    By grsandeep85 in forum Qt Programming
    Replies: 6
    Last Post: 15th November 2013, 04:55
  2. How to copy from Excel and paste to QTableView
    By sms in forum Qt Programming
    Replies: 5
    Last Post: 7th February 2009, 04:58
  3. How to populate delegate with model data.
    By kaushal_gaurav in forum Qt Programming
    Replies: 2
    Last Post: 4th August 2008, 10:31
  4. Replies: 3
    Last Post: 12th June 2008, 12:59
  5. qtablewidget and qtableview
    By dreamer in forum Qt Programming
    Replies: 1
    Last Post: 17th May 2008, 17:01

Tags for this Thread

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.