PHP_XLSXWriter icon indicating copy to clipboard operation
PHP_XLSXWriter copied to clipboard

New lines only appear after Save & Open

Open markruys opened this issue 7 years ago • 3 comments

I'm trying to get new lines inside a header cell. Only after I open the document, save it, and reopen it, the contents are as expected.

Code:

$writer = new XLSXWriter();
$writer->writeSheetHeader('Sheet1', array("1\n22222222"=>'string'),
    $col_options = array('height'=>30,'wrap_text'=>true));
$writer->writeSheetRow('Sheet1', array("a\nbbbbbbbb"),
    $row_options = array('height'=>30,'wrap_text'=>true) );

Opened before a save: before save

And after a save & reopen: after save

These are the Excels:

Excel Mac Office 2017

markruys avatar Oct 28 '17 20:10 markruys

Don't macs use \r as their newline character? Have you tried using \r\n CRLF instead of \n so its more compatible?

mk-j avatar Nov 02 '17 20:11 mk-j

I've unpacked the xlsx file, ran unix2dos on the contents, and zipped it back. Same result, so \n or \r\n does not make a difference.

markruys avatar Nov 02 '17 21:11 markruys

The text "abc\r\ndef", on the mac, I have the same problem, the same file can be wrapped under the window

rocky114 avatar Jun 12 '19 04:06 rocky114