我所做的:
如何找到 \n 并插入新行?例如,我在 A1 中有下一个文本“One\nTwo”。我从 A1 读取文本
$ltr='A1';
$vle=$spreadsheet->getActiveSheet()->getCell($ltr);
Run Code Online (Sandbox Code Playgroud)
在此之后,我尝试在 A1 中再次在 A1 中插入文本并将 \n 替换为一个单元格中的新行
$spreadsheet->getActiveSheet()->getCell($ltr)->setValue("${vle}");
$spreadsheet->getActiveSheet()->getStyle($ltr)->getAlignment()->setWrapText(true);
Run Code Online (Sandbox Code Playgroud)
但这对我不起作用。
因此,如果我打开带有文本的模板,则无法替换单元格中的 \n。我能做什么?
更新。我尝试使用 char(10) 并插入公式(例如)="hello"&char(10)&"world"但仅插入="hello"&char(10)