- 论坛徽章:
- 8
|
本帖最后由 huang6894 于 2014-06-24 17:38 编辑
- use Encode;
- our $local_enc = 'cp936';
- sub decode_cell($){
- my $cell = shift;
- if (!$cell){
- return '';
- }
- if ($cell->{Type} eq 'Text' && defined($cell->{Code})) {
- if ($cell->{Code} eq 'ucs2') {
- $cell->{Val} = decode('UTF16-BE', $cell->{Val});
- }elsif ($cell->{Code} eq '_native_') {
- $cell->{Val} = decode($local_enc, $cell->{Val});
- }
- }
- elsif ($cell->{Type} eq 'Date') {
- }
- elsif ($cell->{Type} eq 'Number') {
- }
- return $cell->{Val};
- }
- foreach $i ($sheet->{MinRow}..$sheet->{MaxRow}) {
- $sheet->{MaxCol} ||= $sheet->{MinCol};
- $line = join("\t", map {encode('utf8', decode_cell($sheet->{Cells}[$i][$_]))} ($sheet->{MinCol}..$sheet->{MaxCol}));
- if ($line =~ m/^\t*$/) {
- $line = '';
- }
- print $line."\n";
- }
- }
- }
复制代码 一个参考 |
|