应该简单但很难谷歌:如何在插入.xlsx电子表格的文本中获得硬回报(如在Excel< Alt + Enter 中)通过perl模块Excel::Writer::XLSX
?
答案 0 :(得分:3)
将“\ n”添加到字符串中,然后调整格式。
(参见文档:https://metacpan.org/pod/Excel::Writer::XLSX#set_text_wrap)
use 5.014;
use warnings;
use Excel::Writer::XLSX;
my $workbook = Excel::Writer::XLSX->new( 'perl.xlsx' );
my $worksheet = $workbook->add_worksheet();
my $format = $workbook->add_format();
$format->set_text_wrap(); # essential for correct "look" in Excel.
$worksheet->write( "B2", "Hi\nExcel!", $format );
^^
答案 1 :(得分:3)
假设您正在使用Excel::Writer::XLSX
,您只需输入换行符:
#!/usr/bin/perl
use warnings;
use strict;
use Excel::Writer::XLSX;
# Create a new Excel workbook
my $workbook = Excel::Writer::XLSX->new( 'perl.xlsx' );
# Add a worksheet
my $worksheet = $workbook->add_worksheet();
my ($row, $col) = (0, 0);
$worksheet->write($row, $col, "Hi Excel!\nHi, again!");
$workbook->close;
大部分内容都是直接基于文档。