How to export Excel with style in PHP
Today, I will talk to you about how to derive Excel with style in PHP. Many people may not know much about it. In order to make you understand better, the editor has summarized the following content for you. I hope you can get something according to this article.
When doing export in your work, you need to export a custom table or dislike the exported Excel format is too ugly.
You need to set the color, font size, bold, merge cells, and so on.
Effect picture:
PHP Code:
/ * Export file * @ return string * / public function export () {$file_name = "report card -" .date ("Y-m-d H:i:s", time ()); $file_suffix = "xls"; header ("Content-Type: application/vnd.ms-excel"); header ("Content-Disposition: attachment; filename=$file_name.$file_suffix"); / / assign template values according to the business. $this- > display ();}
HTML Code:
Report card number, name, Chinese, mathematics, English, 1 Jone 90 85 100 2 Tom 99 85 80 after reading the above content, do you have any further understanding of how to export Excel with style in PHP? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.