Here's an example of how you can use the iCalcreator library to create an iCal file and output it for download: