Creating Excel File Dynamically

There are many ways to do this. You can find a lot of classes and object around the internet. My approach is to use Excel XML feature.

The first step is to create a template using excel and to save it as XML using Excel “Save AS”.

The next step is to open the XML file with some notepad and to analyze the structure.

The last step is to generate the structure using programming language and XML parser.

Don’t forget to use right “content-type” if your application is a web project and an excel file should by downloaded and handled by the Microsoft excel and not by some xml editor. “content-type” in this case should be “application/” download: xml-excel.xml ()
added: 28/07/2010
clicks: 301
description: example of excel xml file

2 Replies to “Creating Excel File Dynamically”

  1. I’m using simplier thing. Each cell value is sepparated by tabs (\t). Name that file as xls and excell will open it. The main problem is openoffice which doesn’t recognize xml nor tab sepparated values. But when you sepparate by tabs it is more readable 😉

  2. Yes tabs or CSV format are useful things, these are OK if the data is not complicated. XML is the best solution if you want to convert to excel some complicated data with formulas in cells, etc…

Leave a Reply