As a developer I often had the need to perform templating using tabular data. For instance you get a spreadsheet customers and want to create a SQL Script to insert them into a database, or you have a list of persons and want to compile a small Html report to send out via mail.
Most of the time I want the path of importing the data into Excel and then doing the templating using Excel formulas. Though not very difficult, you hit some limitations very early. The formula editor gets really messy when working with many fields and at the point where you need to escape or encode things, you will have to fall back to VBA, which is not great for the job either.
Especially if you are doing ad hoc templating, probably for one-time issues, you are really burning time here. Of course another approach is to go the opposite route and write a program that accesses your data and then does the templating. However again when doing just one-time things, this is probably more time than you would like to invest.
I found working with ASP.NET MVC really great since it's approach to templating is straightforward and gives you the best of working with separation of concerns and bare-metal access to the raw markup. With MVC3 the Razor view engine was added that makes markup even less cluttered. I found the RazorEngine project that allows to use the view engine outside of a web context easily and finally had the idea to create TableTemplate.
TableTemplate uses the Razor view engine for templating, where the model is tabular data. At this point the following data sources are supported:
Return the list of files in a directory as a table.
- Excel sheets
Return a table of a sheet.
- SQL Server Queryies
Return a recordset from a query.
tabletemplate-0.3.zip (951,35 kb)