在 PHP 的 PHP 电子表格中的 2 个变量之间添加新行

Add New line between 2 variables in PHPspreadsheet in PHP

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

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

执行代码后excel生成如下

Delhi\nIndia

不如

Delhi
India

你应该使用

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