Bug 12757: Set float type on OpenDocument cells
Test plan:
1. Navigate to Reports > Create from SQL.
2. Create a new report with a name and the following SQL query:
SELECT 'test', 1, '2'
3. Run the report.
4. Under the Download dropdown, select "Open Document Spreadsheet".
5. Verify a ".ods" file is downloaded.
6. Open the downloaded spreadsheet.
7. Verify the two number-like columns are handled as such. This depends
on your choice of spreadsheet software:
- In Excel, the numbers should not have a leading single quote in the
edit-bar when selected.
- In Google Sheets, the numbers should be right-aligned, and
selecting both of them should display their sum in the bottom
toolbar.
8. Run `prove t/Koha/Util/OpenDocument.t` and verify all tests were
successful.
Sponsored-by: Open Fifth
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
parent
63bef24e1d
commit
7edaba25d9
|
|
@ -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 );
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue