PHP,Excel导出换行

Posted jiqing9006

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PHP,Excel导出换行相关的知识,希望对你有一定的参考价值。

技术图片

// 有id,才算真的有发票数据
if ($v['b_invoice_id']) 
    $v['b_invoice_info'] = json_decode($v['b_invoice_json'],true);
    $v['b_invoice_str'] .= '类型:';
    if ((int)$v['b_invoice_purchase'] === 1)  $v['b_invoice_str'] .='(收购)'; 
    if ((int)$v['b_invoice_info']['type'] === 1)  $v['b_invoice_str'] .='普通发票';  else  $v['b_invoice_str'] .= '专用发票'; 
    $v['b_invoice_str'] .= "\\r\\n公司名称/姓名:";
    $v['b_invoice_str'] .= $v['b_invoice_info']['company_name'];
    $v['b_invoice_str'] .= "\\r\\n识别号/身份证:";
    $v['b_invoice_str'] .= $v['b_invoice_info']['company_tax'];
    $v['b_invoice_str'] .= "\\r\\n电话:";
    $v['b_invoice_str'] .= $v['b_invoice_info']['company_telephone']?:'无';
    $v['b_invoice_str'] .= "\\r\\n地址:";
    $v['b_invoice_str'] .= $v['b_invoice_info']['company_address']?:'无';
    $v['b_invoice_str'] .= "\\r\\n开户行:";
    $v['b_invoice_str'] .= $v['b_invoice_info']['company_bank']?:'无';
    $v['b_invoice_str'] .= "\\r\\n开户账号:";
    $v['b_invoice_str'] .= $v['b_invoice_info']['company_account']?:'无';
 else 
    $v['b_invoice_info'] = [];

if ($v['c_invoice_id']) 
    $v['c_invoice_info'] = json_decode($v['c_invoice_json'],true);
    $v['c_invoice_str'] .= '类型:';
    if ((int)$v['c_invoice_info']['type'] === 1)  $v['c_invoice_str'] .='普通发票';  else  $v['c_invoice_str'] .= '专用发票'; 
    $v['c_invoice_str'] .= "\\r\\n公司名称:";
    $v['c_invoice_str'] .= $v['c_invoice_info']['company_name'];
    $v['c_invoice_str'] .= "\\r\\n识别号:";
    $v['c_invoice_str'] .= $v['c_invoice_info']['company_tax'];
    $v['c_invoice_str'] .= "\\r\\n电话:";
    $v['c_invoice_str'] .= $v['c_invoice_info']['company_telephone']?:'无';
    $v['c_invoice_str'] .= "\\r\\n地址:";
    $v['c_invoice_str'] .= $v['c_invoice_info']['company_address']?:'无';
    $v['c_invoice_str'] .= "\\r\\n开户行:";
    $v['c_invoice_str'] .= $v['c_invoice_info']['company_bank']?:'无';
    $v['c_invoice_str'] .= "\\r\\n开户账号:";
    $v['c_invoice_str'] .= $v['c_invoice_info']['company_account']?:'无';

\\r\\n
必须是双引号。

以上是关于PHP,Excel导出换行的主要内容,如果未能解决你的问题,请参考以下文章

php 导出excel 这种方法宽度无法设置 只能自动适应?

phpexcel导出阿里云图片

php控制导出excel的单元格格式

php导出excel怎么设置颜色

用phpexcel 导出不能打开问题

php怎么导出大量数据的Excel,phpexcel