• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Word XML into DOCX

 
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is there any java way (library ?) of converting MS Word XML (template) to DOCX ? Our java application opens XML template , feeds a data in it and saves it again as .xml file.
But our customers must associate the xml with MS Word application. To avoid the association, we would like to give them the DOCX file right away.
Any ideas? Thanks
 
Saloon Keeper
Posts: 7488
171
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've never had to work with the raw XML, but check out whether https://www.docx4java.org/trac/docx4j or https://poi.apache.org/ can do anything with it.
 
Saloon Keeper
Posts: 26291
186
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What, exactly, is supposed to be the difference between "Word XML" and docx? The docx format is Word's XML format. Before docx, Word doc files were in a proprietary binary format.
 
Tim Moores
Saloon Keeper
Posts: 7488
171
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The XML file is only one part of the docx/xlsx/pptx file (which are zip files made up of several files).
 
Tim Holloway
Saloon Keeper
Posts: 26291
186
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ah, that. It's been a while, but if memory serves, the other files are fairly basic and can be manually created. So a Java app creating a DOCX would have to create a ZIP file, insert the XML, create/insert the ancillary stuff, close and rename file (assuming it wasn't created with a .docx extension) and that should pretty much do it.
 
Jiri Nejedly
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is no way to make zip (docx) manually. I tried to save XML template as DOCX and analyze it as ZIP. It contains 22 (!) files, mostly XML but also a picture (customer's logo). To find out what are all files meant for is unreal task.
 
Jiri Nejedly
Ranch Hand
Posts: 107
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried the Dox4J library and found the solution

The code is pretty easy

           
 
CLUCK LIKE A CHICKEN! Now look at this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic