Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Spreadsheet::WriteExcel: How to create a line breaks in a single cell?

by pat_mc (Pilgrim)
on Sep 22, 2011 at 15:47 UTC ( #927407=perlquestion: print w/ replies, xml ) Need Help??
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

Comment on Spreadsheet::WriteExcel: How to create a line breaks in a single cell?
Select or Download Code
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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://927407]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (8)
As of 2014-12-19 12:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (82 votes), past polls