If you follow the mentioned logic, the generation of the excel file can be a headache, so the easiest way to do it is to generate a temporary file file on your system with PHP, write the excel content to it and then generate the download of the file with a custom name (the temporary file will be deleted by the system after some time). If you need to use PHP to create and interact with Microsoft's Excel spreadsheet app, then using PHPExcel is a good way to go. PHPExcel is a library that has been written in PHP and has a complete set of classes, which will allow you to write to and read from different spreadsheet file formats, such as Excel (BIFF) .XLS, Excel 2007 (OFFICEOPENXML) .XLSX, CSV, LIBRE/OPENOFFICECALC .ODS
Continue reading