Do you see how these are separate and distinct tasks that do not necessarily have to be coupled in the way you have specified? Your solution will be much more flexible if you look at the Excel requirement as a
requirement rather than as a mandate to use Excel for data storage. Using an RDBMS, for instance, will suit you far better and more efficiently for the CGI portion. You can then write something that reads from that into Excel or CSV or XML or whatever...