PDA

View Full Version : Best way to populate a QTableView or QTableWidget with Excel data



codeslicer
13th February 2010, 17:08
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:


Export as XML document. I have no idea how to work with XML though.
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?
Or perhaps, is there a ready made solution?


Thanks in advance. :)

~codeslicer

Lykurg
13th February 2010, 17:28
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 :cool:


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 (http://doc.libqxt.org/0.5.0/qxtcsvmodel.html).

codeslicer
13th February 2010, 17:54
Haha, forgot all about Qxt. I'll have to learn XML eventually, but for now I'll look into that.

Thanks. :)

~codeslicer

nattydread
1st February 2011, 12:57
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.