Heim > Artikel > Backend-Entwicklung > php导出excel中,若数据库一列内容中存在换行,则在excel中对应换成多行,如何解决?
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";}