Recently we had a project where we received a rather complicated mail merge Word document that needed to be generated from a web site. If we could handle the Word documents directly, we would have a very flexible method of building similar applications for our clients in the future.

We looked at third party tools and several looked promising initially.

However, they seemed to fail on handling the nested if statements properly. The output in Word or PDF format was rendered incorrectly.

So we looked at using the docx (XML) format and the Microsoft docx SDK. The Word docx format saves the content in XML format which can be manipulated by .NET code just like any other XML file.

We were able to do the merge correctly for the data fields. However, Word doesn't generate the XML consistently and handling the nested if statements in code turned out to be a bit painful. As well, different versions of Word render the doxc mail merge differently so if we left them in (the if statements), we couldn't render them consistently for various clients.

We are pretty sure that we could have kept going and got it working. However, we had a client deadline to meet and there was still some "if" and "maybe" involved.

So we went back to our tried and true solution, build an HTML page to replicate the Word template and generate the output in PDF format. Brute force approach but it works.

Now at the beginning of the project we had a choice: play it safe and build this application using the tried and proven method or push the envelope and hopefully, leap our solution forward in capability.

The play it safe crowd could say "I told you so".

But then if you always play it safe, you never push yourself out of the comfort zone… and you cease to learn.

We now know Word, docx, mail merge and Word to PDF technology a lot better than yesterday. This is very valuable because next time, we will have a working solution and not just a spike that didn't pan out.

You can't do this all the time; sometimes you have put delivering working software ahead of trying new things… technically we are paid to primarily deliver working software and not for things that didn't work out.

But pushing out of your comfort zone once in a while (as a company, team or individual) will pay off in spades later. Playing it safe all the time just ensures that you will stay at the back of the pack.