While generating a report in your project, you might have to download the data into excel file using PHP. In most scenario, you have to display the report in a page and create a link to download the report in the excel file. Well in that scenario, i think i can help you with a simplified class and code of PHP.
I’ve created three files in my example.
1) class.export_excel.php – This file contains the code to export data in excel.
2) export_excel.php – This file contains the code to assign values of the excel header and excel data. The header is one-dimentional array. And the other one is the values to be exported and this one is two-dimentional array. And this file also contain the “fn” named get method ($_GET) varible , which is the name of the file to be generated. If a file called “daily_report.xls” is to be generated then this file can be called as “export_excel.php?fn=daily_report”.
3) test.php – This file contains the data to be displayed in the web page and the same one will be exported in the the excel file. The heading and the values are stored in the session variables. The $_SESSION[‘report_header’] variable contain the headers of the excel file and $_SESSION[‘report_values’] contains the data of the excel.
Remember that $_SESSION[‘report_values’] is a two dimentional array and the column of the array should be same as the no of headers stored in the $_SESSION[‘report_header’] variable.
Now thats all, you can have a link to export_excel.php file with the the name of file to be generated as fn variable i.e. the call to the export_excel.php should export_excel.php?fn=report for generating the file name “report.xls”.
If you have any problem or comment, please contact me at bhattarairoshan[at]yahoo[dot]com.The computer emergency readiness team, cert formulate such strategies to check the invasive and malignant trends of cyber networks. The Microsoft Certified Desktop Support Technician, mcdst exams are very significant for the computer technicians and engineers. If IT professionals want to improve the managerial skills emphatically, itil training is most suitable for them. It is not prerequisite to get full knowledge about the networking administration but the candidates of network plus are recommended to do this job efficiently for better success. If IT professional most advanced career, mcsa certification is very instrumental to achieve the target. The Microsoft certified system engineers, mcse certification is very important for the system analysts and IT engineers to get more expertise in certified manner. The security training is best way to guide the security professionals about all technical strategies.