search
Homephp教程PHP源码简单生成EXCEL
简单生成EXCELMay 25, 2016 pm 05:09 PM

简单的生成EXCEL文件

$arr_list = array(); //数据库读取, 获取要输出到EXCEL的数组

header('Content-type: application/vnd.ms-excel;');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Content-Disposition: attachment; filename=activity.xls'); //filename:文件名
ob_start(); //打开缓存区
include 'file.html'; //输出内容到缓存区
$output = mb_convert_encoding(ob_get_clean(), 'GBK', 'UTF-8'); //缓存区取出,转换编码
echo $output; //输出




<?php
echo implode("t", array_keys($arr_list[0])),"n";
foreach($arr_list as $value){
 echo implode("t", $value),"n";
}
?>

                       


Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.