php_excel / output.php

<?php

$data = array(
	array(‘name‘=>‘Tom‘,‘age‘=>61,‘date‘=>‘2014-09-24 12:00:00‘),
	array(‘name‘=>‘Mark‘,‘age‘=>25,‘date‘=>‘2014-09-23 11:00:00‘),
	array(‘name‘=>‘Lucy‘,‘age‘=>43,‘date‘=>‘2014-09-22 10:00:00‘),
);

$title = array(
	‘姓名‘,
	‘age‘,
	‘时间‘,
);

exportexcel($data,$title);

die();

/**
 * 导出excel
 * @param array $data 数据集
 * @param array $title 标题集
 * @param string $filename 导出的excel文件名
 */
function exportexcel($data=array(),$title=array(),$filename=‘report‘){
	header("Content-type:application/vnd.ms-excel");
	header("Content-Disposition:filename=".$filename.".xls");
	//导出xls 开始
	if (!empty($title))
	{
		foreach ($title as $k => $v)
		{
			$title[$k] = iconv("UTF-8", "GBK",$v);
		}
		$title = implode("\t", $title);
		echo "$title\n";
	}
	if (!empty($data))
	{
		foreach($data as $key=>$val)
		{
			foreach ($val as $ck => $cv)
			{
				$data[$key][$ck] = iconv("UTF-8", "GBK", $cv);
			}
			$data[$key] = implode("\t", $data[$key]);

		}
		echo implode("\n",$data);
	}
}
时间: 2024-10-21 06:23:09

php_excel / output.php的相关文章

output value

http://neuralnetworksanddeeplearning.com/chap3.html // This is a paper.js widget to show a single neuron learning. In // particular, the widget is used to show the learning slowdown that // occurs when the output is saturated. // // The same basic wi

Codeblocks 遇到的问题 Cannot open output file, permission denied

Codeblocks下运行C++的程序时,偶尔会出现  Cannot open output file, permission denied 的问题,导致不能够编译. 在 Stack Overflow 上看到有过类似的遭遇.   链接地址 I have encountered the same problem you have. I found that it may have some relationship with the way you terminate your run resul

数据库服务器Input/output error (故障20170122)

描述: 数据库系统出现告警,登陆查看使用系统命令报错,提示Input/output error 模拟故障处理过程: 检查文件系统时,该文件系统必须卸载.当出现错误时fsck会提示是否修复, 可以用-y参数:不提示是否修复 fsck - check and repair a Linux file system # df -h Filesystem            Size  Used Avail Use% Mounted on /dev/mapper/vg_mysql80-lv_root 2

php输出控制output controll(header, ob_xxx)

关于php的output controll参考文档: http://gywbd.github.io/posts/2015/1/php-output-buffer-in-deep.html http://www.cnblogs.com/liuzhang/p/4161213.html 众所周知,调用header()函数之前不能有任何输出到浏览器,否则会报错. 如何复现这种情况: 1.php.ini设置output_buffering OFF 2.测试代码: echo 2; header("HTTP/

MySQL EXPLAIN Output Format(MySQL运维神技)

摘要: DBA经常会用到的explain来查看SQL语句的执行计划,今天小人斗胆,从MySQL 5.7 Reference Manual中把MySQL EXPLAIN Output Format翻译过来.欢迎拍砖 Explain语句提供了一个select语句执行计划的信息. Explain为每个用了select语句的表,返回一行信息.它列出了表中的顺序输出,MySQL会读取他们,然后再处理.MySQL解决了所有使用嵌套循环连接方法.这意味着MySQL会读取第一个表中的一行,然后在第二个表中找到一

html5,output标签应用举例

<form action="" id="myform" oninput="num.value=parseInt(num1.value)+parseInt(num2.value)">        <input type="number" id="num1">+        <input type="number" id="num2"&g

解决NGINX+PHP-FPM failed to ptrace(PEEKDATA) Input/output error出错问题

网站总是出现bad gateway 提示,时有,时无,查看了一下日志,居然出现一堆错误,如下 [29-Mar-2014 22:40:10] ERROR: failed to ptrace(PEEKDATA) pid 4276: Input/output error (5) [29-Mar-2014 22:53:54] ERROR: failed to ptrace(PEEKDATA) pid 4319: Input/output error (5) [29-Mar-2014 22:56:30]

[20160704]Addition program that use JOptionPane for input and output

1 //Addition program that use JOptionPane for input and output. 2 3 import javax.swing.JOptionPane; 4 5 public class Addition{ 6 public static void main(String[] args) { 7 String firstNumber=JOptionPane.showInputDialog("Enter first integer!"); 8

PIC32MZ tutorial -- Output Compare

Output Compare is a powerful feature of embedded world. The PIC32 Output Compare module compares the values stored in the OCxR and/or the OCxRS registers to the value in the selected timer. When a match occurs, the Output Compare module generates an