php导出excel中,若数据库一列内容中存在换行,则在excel中对应换成多行,如何解决?

WBOY
Release: 2016-06-23 13:33:10
Original
1425 people have browsed it

php导出excel中,若数据库一列内容中存在换行,则在excel中对应换成多行,如何解决?
代码如下:

<?php //验证是否已登录include 'remember_password.php';	header("Accept-Ranges: bytes");	header("Content-type: application/vnd.ms-excel");	header("Content-Disposition: attachment; filename=".$filename);	include("connect.php");	$sql="select * from specific_step";	$query = mysql_query($sql);	echo "序号\t业务名称\t操作步骤\t备注\t录入人\t录入日期";	while($row = mysql_fetch_array($query)){		echo "\n";		echo $row['serial_number']."\t".$row['name']."\t".$row['step']."\t".$row['other']."\t".$row['input_name'].		"\t".$row['input_date'];	}?>
Copy after login


回复讨论(解决方案)

测试例

header("Accept-Ranges: bytes");header("Content-type: application/vnd.ms-excel");header("Content-Disposition: attachment; filename=".@$filename);$ar = array(  "abcd123",  "再来一段换行再换行");echo "序号\t备注\n";foreach($ar as $k=>$v) {  echo "$k\t\"$v\"\n";}
Copy after login
Copy after login
Copy after login

测试例

header("Accept-Ranges: bytes");header("Content-type: application/vnd.ms-excel");header("Content-Disposition: attachment; filename=".@$filename);$ar = array(  "abcd123",  "再来一段换行再换行");echo "序号\t备注\n";foreach($ar as $k=>$v) {  echo "$k\t\"$v\"\n";}
Copy after login
Copy after login
Copy after login



用于从数据库中倒数还是不好用呢?你的代码都是双引号吗

测试例

header("Accept-Ranges: bytes");header("Content-type: application/vnd.ms-excel");header("Content-Disposition: attachment; filename=".@$filename);$ar = array(  "abcd123",  "再来一段换行再换行");echo "序号\t备注\n";foreach($ar as $k=>$v) {  echo "$k\t\"$v\"\n";}
Copy after login
Copy after login
Copy after login



不好意思,刚才字符输入错了,你的很好用,谢谢。
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template