>  기사  >  백엔드 개발  >  php导出excel中,若数据库一列内容中存在换行,则在excel中对应换成多行,如何解决?

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

WBOY
WBOY원래의
2016-06-23 13:33:101396검색

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'];	}?>


回复讨论(解决方案)

测试例

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";}

测试例

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";}



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

测试例

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";}



不好意思,刚才字符输入错了,你的很好用,谢谢。
성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.