how to read and wtrite the xls and xlsx files on the qt?are there any libs that could support these formats of files
-
@nicker-player
You asked this question in 2022 at https://forum.qt.io/topic/139394/how-to-read-write-the-files-with-the-ole-format-like-xls-xlsx-doc. Did you investigate the 3rd party.xls
format readers listed at https://wiki.qt.io/Handling_Microsoft_Excel_file_format? I can't imagine there will be anything more up-to-date than that.One possibility, possibly your best while I think of it, would be to use Excel Automation to read in from
.xls
file and save back with.xlsx
format? So Excel does the conversion for you. Some samples are in https://stackoverflow.com/questions/9918646/how-to-convert-xls-to-xlsx.There are also a few
xls
toxlsx
converters online, some claiming to be free. No idea how good they are. -
I believe you can use OpenOffice/LibreOffice as a library. However, I personally never wanted to have such a huge library in my project.
-
@SimonSchroeder
I agreed that.and in fact its too hard for me to compile the libs into my project. it is too hard.I just want a lib could trans the xls into the xlsx file.but the topics above is too complex for me. -
@nicker-player
I looked years ago at using OpenOffice/LibreOffice as a library, and it is way too large and complicated.Since we seem to have established there is no "lib" already written to translate between the formats, by now you could have used the Qt ActiveX integration to do the necessary loading and saving to convert.
-
@JonB
Ive tried what u just mentioned.but it failed caused I call these codes before the qApp was inited.
some one said that I should do something before new the QAxObject.I dont know what should do to fix it.HRESULT r = OleInitialize(0); if (r != S_OK && r != S_FALSE){...} QAxObject* excel = new QAxObject(); t_ctrl_state = excel->setControl("Excel.Application");
it occured that:
CoCreateInstance failure
QAxBase::setControl: requested control Excel.Application could not be instantiated -
@nicker-player said in how to read and wtrite the xls and xlsx files on the qt?are there any libs that could support these formats of files:
but it failed caused I call these codes before the qApp was inited
Then do it after QApplication initialization.
QAxObject is a QObject and QObjects require QApplication instance. -
but if that.what should i do to call this in a std:: thread .dose the qloop would fail?
-
@nicker-player Sorry, I don't know what you mean. Why do you need a thread?
-
@nicker-player said in how to read and wtrite the xls and xlsx files on the qt?are there any libs that could support these formats of files:
QAxBase::setControl: requested control Excel.Application could not be instantiated
Is Excel installed on the machine you are running this on?