哪位对perl生成中文Excel文件有研究

哪位对perl生成中文Excel文件有研究

哪位对perl生成中文Excel文件有研究
给出例子也可以
这是我的
我觉得没有任何新的突破
#!/usr/bin/perl -w
#Thanks:
# http://perlchina.sun126.com/cgi-bin/ccb/topic_view.cgi?forum=5&article_id=0005051001180443&publishtime_id=0005051001180443&new_window=1&ip=1&t=1&page=330&search_word=excel
# http://search.cpan.org/~jmcnamara/Spreadsheet-WriteExcel-2.17/lib/Spreadsheet/WriteExcel.pm#WORKSHEET_METHODS


use Spreadsheet::WriteExcel;
use Spreadsheet::ParseExcel::FmtUnicode;
use Unicode::Map();



# Create a new Excel workbook
my $workbook = Spreadsheet::WriteExcel->new("李鹏.xls");
my $Map = new Unicode::Map("GB2312");


my $worksheet = $workbook->add_worksheet("test");


$format1 = $workbook->add_format(); # Add a format
$format1->set_bold();
$format1->set_color('red');

$format2 = $workbook->add_format(); # Add a format
$format2->set_bold();
$format2->set_color('green');



@detail = (
'张三','lpx@hotmail.com','接口组',
'李四','gzh@hotmail.com','接口组',
'王五','crote@hotmail.com','接口组'
);

$worksheet->write_unicode(0,0,$Map->to_unicode("姓名"));
$worksheet->write_unicode(0,1,$Map->to_unicode("MSN"));
$worksheet->write_unicode(0,2,$Map->to_unicode("所在组"));

for($row=1,$num=0,$col=0;$num<@detail;$num++,$col++)
{

$worksheet->write_unicode($row,$col,$Map->to_unicode($detail[$num]),($row%2==0)?$format1:$format2);
if($col == 2)
{
$col=-1;
$row++;
}
}



$workbook->close() ;


哪位好经典的例子
谢谢了
hi,my ime is broken,so...
hi,my ime is broken,so....................
please use the search box in bbs,and input Excel,you will get a lot of results.
there were some chinese passage for you:
http://www-128.ibm.com/developerworks/cn/linux/sdk/perl/culture-8/index.html
you can also read:
http://search.cpan.org/~jmcnamara/Spreadsheet-WriteExcel-2.17/lib/Spreadsheet/WriteExcel.pm
但是有关向Excel中写入中文的文章却不多
只找到一篇

所以您要是有 中文批量写入Excel的实用好例子给我看看呗
我上面的例子实用性就不大了,本来一个人的信息可以作为一行写入的,但是那样我就不会控制对中文的转换了,只能一个一个的写,所以只是好看罢了

谢谢了
我把你的例子改了改,在我.
我把你的例子改了改,在我这里可以通过。
你试试,如果有问题,请联系我:flw@cpan.org

[quote]use Spreadsheet::WriteExcel;
use Encode qw(encode decode);

# Create a new Excel workbook
my $workbook = Spreadsheet::WriteExcel->new("ttt.xls");

my $worksheet = $workbook->add_worksheet("test");


$format1 = $workbook->add_format(); # Add a format
$format1->set_bold();
$format1->set_color('red');

$format2 = $workbook->add_format(); # Add a format
$format2->set_bold();
$format2->set_color('green');



@detail = (
'张三','lpx@hotmail.com','接口组',
'李四','gzh@hotmail.com','接口组',
'王五','crote@hotmail.com','接口组'
);

$worksheet->write_string(0,0,decode( 'gb2312', "姓名" ));
$worksheet->write_string(0,1,decode( 'gb2312', 'MSN' ));
$worksheet->write_string(0,2,decode( 'gb2312', '所在组' ));

for($row=1,$num=0,$col=0;$num<@detail;$num++,$col++)
{

$worksheet->write_string($row,$col,decode( 'gb2312', $detail[$num] ),($row%2==0)?$format1:$format2);
if($col == 2)
{
$col=-1;
$row++;
}
}



$workbook->close() ; [/quote]