简体   繁体   中英

Document templates: JavaScript as replacement for Word?

We currently use Word for mail merge (labels) and personalized greeting cards (contact name in the text).

Because our contact information is stored on a Web platform (SharePoint), I was thinking about replacing the Word templates with Web-based templates. The idea would be to use a JavaScript templating engine like Mustache to generate the html documents. Or another approach would be to use XSLT.

Has this been done already? What would be the pros and cons of Web templating vs. Word?

For us it proved quite useful to use Templates stored in the Open Document Format. We then parse the contained script tags (text:script) to build XSL stylesheets for content and styles.

The data is stored in a Postgres database and formatted as XML directly by the database . When the XML is transformed using the XSL stylesheets, the contents of the ODF documents will be the result.

Those generated ODF documents are then processed with LibreOffice to generate a wide range of output formats.

The pros from this workflow are:

  • full SQL available to prepare data for processing
  • quick data processing since a good database backs it
  • familiar word processing applications serve as template editor (LibreOffice, OpenOffice, KWord, Mircosoft Word, …)
  • pretty good layouting (if you are satisfied with layouts of common office applications)
  • XSL as template language provides much flexibility
  • can produce spreadsheets and presentations in addition to text documents
  • based on standardized components and formats

The cons are:

  • some software required to implement the outlined steps (we use a self-developed application, but the less powerful ODF-XSLT should do to try out the approach)
  • requires new components in an otherwise Microsoft-centered setup (does probably apply according to the technologies mentioned in the question)
  • knowledge of SQL and XSL required for complex jobs

You need to be aware that this setup is intended to be used with a server for report generation and therefore complex to setup initially.

I would argue against using HTML and JavaScripts to generate reports due to HTML not being suitable for printed layouts. Instead just use a web application entering data and triggering report generation with a setup similar to the one described above.

It might also be worth investigating the production of LaTeX files from XSL instead of ODF if you are aiming for superior layout.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM