From: Robert Bohne Date: Sun, 20 Feb 2011 19:04:19 +0000 (+0100) Subject: Fixed RT #65764 - enable cell-comments X-Git-Tag: v0.33~1 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=997b1ce3a3b98096a37d1733af806017ffa98293;p=p5sagit%2FExcel-Template.git Fixed RT #65764 - enable cell-comments --- diff --git a/lib/Excel/Template/Element/Cell.pm b/lib/Excel/Template/Element/Cell.pm index a9a610b..edc2a4e 100755 --- a/lib/Excel/Template/Element/Cell.pm +++ b/lib/Excel/Template/Element/Cell.pm @@ -99,6 +99,11 @@ sub render $context->active_format, ); + my $comment = $context->get($self, 'COMMENT'); + if (defined $comment && length $comment){ + $context->active_worksheet->write_comment($row, $col,$comment); + } + return 1; } diff --git a/t/030.xml b/t/030.xml new file mode 100644 index 0000000..6479788 --- /dev/null +++ b/t/030.xml @@ -0,0 +1,7 @@ + + + Test1 + + + + \ No newline at end of file diff --git a/t/030_cell_comment.t b/t/030_cell_comment.t new file mode 100644 index 0000000..a1d8e44 --- /dev/null +++ b/t/030_cell_comment.t @@ -0,0 +1,32 @@ +use strict; + +use Test::More tests => 4; + +use lib 't'; +use mock; +mock::reset; + +my $CLASS = 'Excel::Template'; +use_ok( $CLASS ); + +my $object = $CLASS->new( + filename => 't/030.xml', +); +isa_ok( $object, $CLASS ); + +ok( $object->write_file( 'filename' ), 'Something returned' ); + +my @calls = mock::get_calls; + +is_deeply([@calls],[ + q[Spreadsheet::WriteExcel::new( 'filename' )], + q[Spreadsheet::WriteExcel::add_format( '' )], + q[Spreadsheet::WriteExcel::add_worksheet( 'cell' )], + q[Spreadsheet::WriteExcel::Worksheet::new( '' )], + q[Spreadsheet::WriteExcel::Worksheet::write( '0', '0', 'Test1', '1' )], + q[Spreadsheet::WriteExcel::Worksheet::write_comment( '0', '0', 'Test1' )], + q[Spreadsheet::WriteExcel::Worksheet::write( '0', '1', 'Test2', '1' )], + q[Spreadsheet::WriteExcel::Worksheet::write_comment( '0', '1', 'Test2' )], + q[Spreadsheet::WriteExcel::Worksheet::write( '0', '2', 'Test3', '1' )], + q[Spreadsheet::WriteExcel::close( '' )], +],'Calls match up'); diff --git a/t/Spreadsheet/WriteExcel/Worksheet.pm b/t/Spreadsheet/WriteExcel/Worksheet.pm index 0436735..77af11a 100644 --- a/t/Spreadsheet/WriteExcel/Worksheet.pm +++ b/t/Spreadsheet/WriteExcel/Worksheet.pm @@ -19,7 +19,7 @@ sub new { my @funcs = qw( write_string write_number write_blank write_url write_formula write_date_time write set_row set_column keep_leading_zeros insert_bitmap freeze_panes - set_landscape set_portrait merge_range hide_gridlines autofilter + set_landscape set_portrait merge_range hide_gridlines autofilter write_comment ); foreach my $func ( @funcs ) {