Next.js Discord

Discord Forum

Asking for recommendation on how to deal with Open Office XML Documents (.docx/.xlsx)

Unanswered
iyxan23 posted this in #help-forum
Open in Discord
I'm currently in need of a way of being able to modify an ooxml document (.docx and .xlsx) on nextjs (well technically nodejs), something like docxtemplater, but free? I cannot afford the (atrocious) pricing of the modules I needed. Asking for suggestions to anybody who had encountered this same roadblock!

Thinking of doing that in a different language, perhaps rust or python; if there are any similar libraries out there.

13 Replies

did a long research, stumbled upon a few interesting libraries but not enough for my usecase: https://github.com/bokuweb/docx-rs/ (can be used to interface to JS with wasm bindings), and a python library idk
if anybody's wondering, what i decided to do is to manually parse the XML of word/document.xml from a docx file and set up a simple visitor pattern that searches for element with type w:p, and do a simple regex on its child w:r>w:t if it exists.
a reference to the structure of an ooxml file: http://officeopenxml.com/WPcontentOverview.php
very old website yet very useful
the complete ooxml spec can be downloaded at https://ecma-international.org/publications-and-standards/standards/ecma-376/ for free
heck i actually managed to do it
here's the code incase anyone wanted to expand it from here lol:
docx-replacer.ts
docs-closing-tags-list.ts
needs zip.js and fast-xml-parser as deps
thinking of publishing this as a lib, might be useful for someone out there
heya sorry for bumping, i had just published this on github in case someone needed it: https://github.com/iyxan23/ooxml-templater-js :)
basic docx templating is working as expected, xlsx is a work-in-progress