【问题标题】:Add New line between 2 variables in PHPspreadsheet in PHP在 PHP 的 PHP 电子表格中的 2 个变量之间添加新行
【发布时间】:2021-02-18 13:43:05
【问题描述】:

我创建了一个链接,使用以下代码从数据库中导出 excel 中的数据

$sheet->setCellValue('A1', $row['address_line_1'] . '\n' . $row['address_line_2']);

执行代码后生成的excel如下

Delhi\nIndia

不像

Delhi
India

【问题讨论】:

  • 它是"\n",注意引号。

标签: php phpspreadsheet


【解决方案1】:

你应该使用

$sheet->setCellValue('A1', "Delhi\nIndia");
$sheet->getStyle('A1')->getAlignment()->setWrapText(true);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-10-29
    • 2019-10-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-03
    • 1970-01-01
    相关资源
    最近更新 更多