0

I’m having some trouble coming up with a future-proof-ish design for reports for a company. Essentially the requirements are:

  • Be able to pull whatever data from the database
  • Generate formatted report from that data by populating a template (HTML, docx)
  • Export to Word and/or PDF

So initially I made an API endpoint per report (this is a web app), and had PDFs generated and formatted correctly.

But now I need to get the data into .docx/Word format, and I’m trying to figure out how I can design something as D.R.Y. as possible so that I don’t have to put in a TON of work every time the company decides they need another report (they’ve done this two, three times which is how I became aware that I had coded myself into a corner).

Every report I’ve done thus far has been done via a “brute-force” method: code the queries needed for the report, format the data, and then render to PDF (using HTML to PDF via phantomjs).

The complexity occurred when the company came back and said “Hey, we need all of those reports in Word format, also we have 3 other new reports that we need and a report that is a slight variation on the old one but +/- 2 fields”.

I am just having trouble coming up with a solid design/abstraction here, one that doesn’t send me down a week long hacking spree every time a requirement changes.

mpetts
  • 106
  • 5
  • I have the initial set of reports built from HTML templates by hand, templating with Mustache, rendering to PDF with phantomjs. The issue being that each report required WAY too much code to get done, and my design wasn't even flexible enough to handle the rendering to Word requirement elegantly. I'm trying an out of the box solution (JasperReports) now, because I gotta get this project done. I'll leave the question though, because I'm still curious. – mpetts Nov 10 '17 at 19:43
  • @Neoromanzer No I haven't. I'll check those out – mpetts Nov 11 '17 at 06:43

0 Answers0