Show
Ignore:
Timestamp:
10/23/08 19:38:23 (5 years ago)
Author:
mizuno_takaaki
Message:

lang/perl/Catalyst-View-Spreadsheet-WriteExcel?: object method supported

Location:
lang/perl/Catalyst-View-Spreadsheet-WriteExcel/trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • lang/perl/Catalyst-View-Spreadsheet-WriteExcel/trunk/lib/Catalyst/View/Spreadsheet/WriteExcel.pm

    r21985 r21986  
    4444        my $x = 0; 
    4545        for my $key (@{$c->stash->{header}}) { 
    46             $sheet->write_utf16be_string($y, $x, utf8($rec->{$key})->utf16be); 
     46            my $package = ref $rec; 
     47            my $data = $package->can($key) ? $rec->$key : $rec->{$key}; 
     48            $sheet->write_utf16be_string($y, $x, utf8($data)->utf16be); 
    4749            $x++; 
    4850        } 
  • lang/perl/Catalyst-View-Spreadsheet-WriteExcel/trunk/t/lib/TestApp.pm

    r21985 r21986  
    2020    my @list = ( 
    2121        {name => 'mizuno', score => 10,}, 
    22         {name => 'aql', score => 130,}, 
    23         {name => '$B$R$G$*$-(B', score => 200, }, 
     22        TestApp::Data->new({name => 'aql', score => 130,}), 
     23        TestApp::Data->new({name => '$B$R$G$*$-(B', score => 200, }), 
    2424        {name => '$B$N$V$*(B', score => 70, }, 
    2525    ); 
     
    3131} 
    3232 
     33package TestApp::Data; 
     34use base qw/Class::Accessor::Fast/; 
     35__PACKAGE__->mk_accessors(qw/name score/); 
     36 
    33371;