How to open and edit the doc or docx file in qt?
-
How can i do to create an editor which can open and edit doc or docx file in a widget? Is there any existing tools to do this?
I try to use the "Abiword" , but it seems to be paused. so I want another one.
Please give me some advice. -
Hi
You could use LibreOffice. it edits word docs really well.Depending on your real requirements there is also the option of parsing the docx yourself since its xml.
However, i have not seen a nice Qt widget that can just edit Docx Files and
doc files that are binary are even more pain. -
Hi
Yeah i think its a huge task to separate writer.exe code to be only about
docx/doc. You could just spawn it with QProcess from your app.But what types of word docs do you need to handle ?
If any word doc must be editable then i doubt its possible directly in a Qt app with out word being installed.
I assume you want to do this without having MS office installed ?
as else QAxWidget can be used. -
@Puzzlesaur said in How to open and edit the doc or docx file in qt?:
but the libreoffice is too large , i don't need open or edit the xlsx、 ppt file
Perhaps you could take a look at DuckX.
Here extract form GitHub project page:DuckX was created when I was looking for a C++ library which can properly parse MS Word .docx files, but couldn't find any
I don't know if it really works and how good it is...
Good luck
-
@mrjj said in How to open and edit the doc or docx file in qt?:
Hi
Yeah i think its a huge task to separate writer.exe code to be only about
docx/doc. You could just spawn it with QProcess from your app.
But what types of word docs do you need to handle ?
If any word doc must be editable then i doubt its possible directly in a Qt app with out word being installed.
I assume you want to do this without having MS office installed ?
as else QAxWidget can be used.I want to do this task on Linux system. so I think ActiveX may not work with me.
-
@Puzzlesaur
Yes, you won't be able to useQAx...
anything under Linux.Looks like your only starting point is @KroMignon's DuckX link. A docx file is basically a zipped file containing XML. That's why that code uses a zip library to unzip/zip and an XML library to read/write the XML.
I think you'll find it only handles the very simplest of docx files, maybe with some paragraphs and some tables. I don't think it will handle anything more complicated than that without you understanding the XML in docx files and expanding the code to deal with what you want on a case-by-case basis.
If you are writing your Qt program in Python/PyQt/PySide (are you? :) ) a more comprehensive library would be Python's own python-docx. Just looking through its code would give you an idea of how much more there is to handle than DuckX seems to provide....