Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
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 avoiding work at the Monastery: (7)
As of 2015-07-05 05:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (60 votes), past polls