PHP operation Excel file with Chinese content and file export

Source: Internet
Author: User
Tags php example
This article mainly introduces the PHP operation with the Chinese content of Excel file and file export, interested in the reference of friends, I hope to be helpful to everyone.

This example describes the PHP export Chinese content Excel file class, as follows:

<?php class toexcel{public $link = null; function __construct () {}/*************************************************************************** * $  Mapping: Array header information $map=array (' No ', ' Name ', ' Email ', ' age '); * $datalist: Result set found in database * $fileName: Excel file name * return:excel format file **************************************************** /Public Function Toexcel ($mapping, $datalist, $fileName) {header ("content-type:application/   Vnd.ms-excel "); Header ("Content-disposition:filename=". Iconv (' Utf-8 ', ' gb2312 ', $fileName). "   XLS ");   Echo ' 

Method Two

<?php header ("content-type:application/vnd.ms-execl"); Header ("content-disposition:attachment; Filename=myexcel.xls "); Header ("Pragma:no-cache"); Header ("expires:0"); /*first line*/$data 1 = "Chinese test"; $data 1=mb_convert_encoding ($data 1, "GB2312", "UTF-8"); echo $data 1. " \ t "; echo "World". " \ t "; echo "\t\n"; /*start of second line*/echo "This was second line". " \ t "; echo "Hi,pretty girl". " \ t "; echo "\t\n";?>

Summary: the above is the entire content of this article, I hope to be able to help you learn.

Related recommendations:

PHP example analyzes the use of MySQL transaction processing skills

PHP-based multithreading for multi-threaded crawling

PHP creates linked lists and adds, deletes, updates, and loops for linked list nodes

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.