I need to create an Excel 2007 template workbook and devise the means to programmatically populate it with a dataset. The template workbook should include all of the formatting and boilerplate content that will appear in the final result, but will not inlcude any data rows.
The data injection process must be able to dynamically insert data into the workbook, hopefully without any knowledge of the styling, conditional columns, calculations, charts etc that are present in the template.
I have been experimenting with the new OpenXml Document Formats SDK 2.0 (using C#) and found that it offers a lot of flexibility in reading and manipulating Excel workbooks. However, the more I delve into it, the more I discover that it requires an intimate knowledge of the inner workings of Excel. For example, the fact that tables, worksheets and the calculation chain are all maintained separately inside the package is testing the limits of my understanding. I am concerned that my "solution" might exhibit unexpected behavior in different data scenarios.
So, I am wondering whether there is a more robust approach ...
Given that Excel is capable of binding to external data sources, including Xml data, is it possible that my dataset could be saved as an Xml file and injected into the workbook package file? In other words, is it feasible for an "external" data source to be inside the workbook package? If so, how would I go about defining a placeholder table in the template that would automatically bind to the injected data when the workbook is opened?
Many thanks for your suggestions.