I have some questions about customizing export result(excel) with php. The idea is i want to export my query of my raw data (mysql table) to excel file but with some customization in the result. for example i want to have result which is summary of the table like below table:
The 3rd column until 7th column is named based on the last 5 days of my report date.
My idea is: 1. create temporary table using format as the result table i want to generate 2. Insert the table with my raw data. 3. Delete those table.
Is that efective?or is there any better idea?
You can always use a view. Which is essentially a select statement with your data in there, and which will be updated whenever your tables are updated. Then you can just do a 'select * from view_name
' and export that into your excel.
Depending on the size of the data, there is no need to think about performance.
You can have a temp table. Depending on the data, this is very fast if you can select and insert the data based on indexes. Then you make a SELECT * from tmp_table;
and you have all your data
You can just join over the different tables, get the data and then loop (read as foreach
) over the result array and change the data and export it afterwards