PHP exports the Excel sample code with styles and the excel sample code

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.