1############################################################################### 2# 3# Tests the output of Excel::Writer::XLSX against Excel generated files. 4# 5# Copyright 2000-2021, John McNamara, jmcnamara@cpan.org 6# 7 8use lib 't/lib'; 9use TestFunctions qw(_compare_xlsx_files _is_deep_diff); 10use strict; 11use warnings; 12 13use Test::More tests => 1; 14 15############################################################################### 16# 17# Tests setup. 18# 19my $filename = 'formula_results01.xlsx'; 20my $dir = 't/regression/'; 21my $got_filename = $dir . "ewx_$filename"; 22my $exp_filename = $dir . 'xlsx_files/' . $filename; 23 24my $ignore_members = [ 'xl/calcChain.xml', 25 '\[Content_Types\].xml', 26 'xl/_rels/workbook.xml.rels' ]; 27my $ignore_elements = {}; 28 29 30############################################################################### 31# 32# Test the creation of a simple Excel::Writer::XLSX file with formula errors. 33# 34use Excel::Writer::XLSX; 35 36my $workbook = Excel::Writer::XLSX->new( $got_filename ); 37my $worksheet = $workbook->add_worksheet(); 38 39$worksheet->write_formula( 'A1', '1+1', undef, 2 ); 40$worksheet->write_formula( 'A2', '"Foo"', undef, 'Foo' ); 41$worksheet->write_formula( 'A3', 'IF(B3,FALSE,TRUE)', undef, 'TRUE' ); 42$worksheet->write_formula( 'A4', 'IF(B4,TRUE,FALSE)', undef, 'FALSE' ); 43$worksheet->write_formula( 'A5', '#DIV/0!', undef, '#DIV/0!' ); 44$worksheet->write_formula( 'A6', '#N/A', undef, '#N/A' ); 45$worksheet->write_formula( 'A7', '#NAME?', undef, '#NAME?' ); 46$worksheet->write_formula( 'A8', '#NULL!', undef, '#NULL!' ); 47$worksheet->write_formula( 'A9', '#NUM!', undef, '#NUM!' ); 48$worksheet->write_formula( 'A10', '#REF!', undef, '#REF!' ); 49$worksheet->write_formula( 'A11', '#VALUE!', undef, '#VALUE!' ); 50$worksheet->write_formula( 'A12', '1/0', undef, '#DIV/0!' ); 51 52 53$workbook->close(); 54 55 56############################################################################### 57# 58# Compare the generated and existing Excel files. 59# 60 61my ( $got, $expected, $caption ) = _compare_xlsx_files( 62 63 $got_filename, 64 $exp_filename, 65 $ignore_members, 66 $ignore_elements, 67); 68 69_is_deep_diff( $got, $expected, $caption ); 70 71 72############################################################################### 73# 74# Cleanup. 75# 76unlink $got_filename; 77 78__END__ 79