diff --git a/Koha/Util/OpenDocument.pm b/Koha/Util/OpenDocument.pm index ac9cbc60e9..1269fe2c0d 100644 --- a/Koha/Util/OpenDocument.pm +++ b/Koha/Util/OpenDocument.pm @@ -21,6 +21,7 @@ use Modern::Perl; use File::Basename qw( dirname ); use OpenOffice::OODoc qw( odfDocument odfWorkingDirectory ); +use Scalar::Util qw(looks_like_number); use parent qw( Exporter ); @@ -70,6 +71,7 @@ sub generate_ods { for ( my $i = 0 ; $i < $nb_rows ; $i++ ) { for ( my $j = 0 ; $j < $nb_cols ; $j++ ) { my $cellval = $input_rows[$i][$j]; + $odf_doc->cellValueType( $odf_rows[$i], $j, 'float' ) if looks_like_number($cellval); $odf_doc->cellValue( $odf_rows[$i], $j, $cellval ); } } diff --git a/t/Koha/Util/OpenDocument.t b/t/Koha/Util/OpenDocument.t index 0d41325ff1..4ccc919a12 100755 --- a/t/Koha/Util/OpenDocument.t +++ b/t/Koha/Util/OpenDocument.t @@ -19,7 +19,7 @@ use Modern::Perl; use File::Temp qw/tempfile/; use Test::NoWarnings; -use Test::More tests => 5; +use Test::More tests => 7; BEGIN { use_ok('Koha::Util::OpenDocument'); } @@ -40,4 +40,6 @@ $filepath = $fh2->filename; my $content2 = [ [ 'A', 'B' ], [ '1', '2' ] ]; $ret = generate_ods( $filepath, $content2 ); ok( defined $ret, 'Call generate_ods with 2x2 content' ); +is( $ret->cellValueType( 0, 0, 0 ), 'string', 'Text cells have string type' ); +is( $ret->cellValueType( 0, 1, 0 ), 'float', 'Number cells have float type' ); close $fh2;