PHP exports the Excel sample code with styles and the excel sample code
Preface
When exporting data in your work, you need to export a custom table or discard the exported Excel format. At this time, you need to set the color, font size, bold, merge cells, and so on. This article tells you how to do it through examples. Let's take a look at it.
Let's take a look:
Instance code
PHP code:
/*** Export file * @ return string */public function export () {$ file_name = "Transcript -". 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 values to the template based on the business. $ This-> display ();}
HTML code:
<Html xmlns: o = "urn: schemas-microsoft-com: office" xmlns: x = "urn: schemas-microsoft-com: office: excel "xmlns =" http://www.w3.org/TR/REC-html40 ">
The above is all the content in this article. This article introduces the details in detail through examples. I hope it will help you in your study and work. If you have any questions, please leave a message. Thank you for your support for the help house.