Unsolved Reading data from an excel file using qfiledislog
-
Hey I want to read data from an excel file to plot a graph using qfiledialog. Please help me. How do I read the variables from the file and use it to plot a graph
-
@emeka_o You can't read Excel files using QFileDialog. QFileDialog is a dialog to let the user select a file. There is nothing in Qt to read content of an Excel file in an easy way. You will need to use a library or use https://wiki.qt.io/Handling_Microsoft_Excel_file_format
-
@jsulm but can you open an excel file using qfiledialog?
I’ve seen cases where you can open .txt files. I’m looking for a way to load a spreadsheet file to get the variables -
@emeka_o QFileDialog does not open any files. QFile does...
-
@jsulm oh my bad. Can I use qfile to open an excel file to read the data from it and store it?
-
@emeka_o Of course you can. But then you will have to parse the file by yourself which is a hard to achieve task as the format is complex. That's why I gave you a link where it is described how you can read Excel files.
-
Would it be the same method for a .txt file?
-
Hi
What type of text file ?say if you had a comma separated values file ( a text file )
then it would be much easier to read into a Qt program and do something with it.so if you saved from excel a CSV file it would be easy to read in Qt.
-
@mrjj how do I open and read a csv file to get the variables to store in let’s say a vector
-
Hi
With Qfile and QString and its split function.
You would loop over each line and then split on comma or Tab (as excel uses)
like here. first answer
https://stackoverflow.com/questions/27318631/parsing-through-a-csv-file-in-qtor you could use a lib
https://github.com/iamantony/qtcsv -
Will this be able to open any csv file without putting the file name in the code?
-
@emeka_o said in Reading data from an excel file using qfiledislog:
Will this be able to open any csv file without putting the file name in the code?
For that use QFileDialog to let the user select the file to open and then open it using QFile, is really not that hard. Or what is your use case?
-
I want the user to be able to select the csv file and I want to be able to save the the data in variables
-
-
thank you