http://www.perlmonks.org?node_id=927407

pat_mc has asked for the wisdom of the Perl Monks concerning the following question:

Hi, Monks!

I have finally given Spreadsheet::WriteExcel a chance and am liking it a lot. Basically, I am populating cells like so:

$worksheet1 -> write( $row,  $column, "$content", $format );

There was one thing, however, I was unable to do: I want to include a line break between entries in a single cell. In Excel, this would be done with ALT + ENTER ... but I have no idea what to write into a cell using Spreadsheet::WriteExcel. I already tried

$cell = "Line \n Line"

but that didn't work.

Anyone got any help for me?

Thanks in advance and kind regards -

Pat

Replies are listed 'Best First'.
Re: Spreadsheet::WriteExcel: How to create a line breaks in a single cell?
by runrig (Abbot) on Sep 22, 2011 at 15:52 UTC
    I'm pretty sure that should work. Are you sure the row height is large enough to fully display the cell?
    See: Excel single cell line breaks and Spreadsheet::WriteExcel Newline character
    Summary:
    my $wb = Spreadsheet::WriteExcel->new('tmp.xls'); my $format = $wb->add_format(); $format->set_text_wrap() ; my $ws = $wb->add_worksheet(); $ws->write(0, 0, "This is\na multiline cell", $format); $wb->close();
      Thanks, runrig!

      I did try "\n" before ... now it all works. That solved the problem. Thanks again for responding!
Re: Spreadsheet::WriteExcel: How to create a line breaks in a single cell?
by jmcnamara (Monsignor) on Sep 22, 2011 at 22:53 UTC