Skip to content

Commit a703853

Browse files
committed
worksheet: add support for IMAGE() future function
Issue #293
1 parent 24563bc commit a703853

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

lib/Excel/Writer/XLSX.pm

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6624,6 +6624,7 @@ The following list is taken from the MS XLSX extensions documentation on future
66246624
_xlfn.ACOTH
66256625
_xlfn.AGGREGATE
66266626
_xlfn.ARABIC
6627+
_xlfn.ARRAYTOTEXT
66276628
_xlfn.BASE
66286629
_xlfn.BETA.DIST
66296630
_xlfn.BETA.INV
@@ -6643,6 +6644,7 @@ The following list is taken from the MS XLSX extensions documentation on future
66436644
_xlfn.CHISQ.INV.RT
66446645
_xlfn.CHISQ.TEST
66456646
_xlfn.COMBINA
6647+
_xlfn.CONCAT
66466648
_xlfn.CONFIDENCE.NORM
66476649
_xlfn.CONFIDENCE.T
66486650
_xlfn.COT
@@ -6678,6 +6680,8 @@ The following list is taken from the MS XLSX extensions documentation on future
66786680
_xlfn.GAUSS
66796681
_xlfn.HYPGEOM.DIST
66806682
_xlfn.IFNA
6683+
_xlfn.IFS
6684+
_xlfn.IMAGE
66816685
_xlfn.IMCOSH
66826686
_xlfn.IMCOT
66836687
_xlfn.IMCSC
@@ -6688,9 +6692,13 @@ The following list is taken from the MS XLSX extensions documentation on future
66886692
_xlfn.IMTAN
66896693
_xlfn.ISFORMULA
66906694
ISO.CEILING
6695+
_xlfn.ISOMITTED
66916696
_xlfn.ISOWEEKNUM
6697+
_xlfn.LET
66926698
_xlfn.LOGNORM.DIST
66936699
_xlfn.LOGNORM.INV
6700+
_xlfn.MAXIFS
6701+
_xlfn.MINIFS
66946702
_xlfn.MODE.MULT
66956703
_xlfn.MODE.SNGL
66966704
_xlfn.MUNIT
@@ -6728,13 +6736,18 @@ The following list is taken from the MS XLSX extensions documentation on future
67286736
_xlfn.T.INV
67296737
_xlfn.T.INV.2T
67306738
_xlfn.T.TEST
6739+
_xlfn.TEXTAFTER
6740+
_xlfn.TEXTBEFORE
6741+
_xlfn.TEXTJOIN
67316742
_xlfn.UNICHAR
67326743
_xlfn.UNICODE
6744+
_xlfn.VALUETOTEXT
67336745
_xlfn.VAR.P
67346746
_xlfn.VAR.S
67356747
_xlfn.WEBSERVICE
67366748
_xlfn.WEIBULL.DIST
67376749
WORKDAY.INTL
6750+
_xlfn.XMATCH
67386751
_xlfn.XOR
67396752
_xlfn.Z.TEST
67406753

lib/Excel/Writer/XLSX/Worksheet.pm

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2935,6 +2935,7 @@ sub _prepare_formula {
29352935
$formula =~ s/\b(HYPGEOM.DIST\()/_xlfn.$1/g;
29362936
$formula =~ s/\b(IFNA\()/_xlfn.$1/g;
29372937
$formula =~ s/\b(IFS\()/_xlfn.$1/g;
2938+
$formula =~ s/\b(IMAGE\()/_xlfn.$1/g;
29382939
$formula =~ s/\b(IMCOSH\()/_xlfn.$1/g;
29392940
$formula =~ s/\b(IMCOT\()/_xlfn.$1/g;
29402941
$formula =~ s/\b(IMCSCH\()/_xlfn.$1/g;
@@ -3081,8 +3082,8 @@ sub write_formula {
30813082
# Check that row and col are valid and store max and min values
30823083
return -2 if $self->_check_dimensions( $row, $col );
30833084

3084-
# Remove the = sign if it exists.
3085-
$formula =~ s/^=//;
3085+
# Expand out the formula.
3086+
$formula = $self->_prepare_formula($formula);
30863087

30873088
# Write previous row if in in-line string optimization mode.
30883089
if ( $self->{_optimization} == 1 && $row > $self->{_previous_row} ) {

t/worksheet/sub_prepare_formula.t

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use strict;
99
use warnings;
1010
use Excel::Writer::XLSX::Worksheet;
1111

12-
use Test::More tests => 179;
12+
use Test::More tests => 180;
1313

1414

1515
###############################################################################
@@ -98,6 +98,7 @@ my @testcases = (
9898
['F.INV()', '_xlfn.F.INV()'],
9999
['GAMMA()', '_xlfn.GAMMA()'],
100100
['GAUSS()', '_xlfn.GAUSS()'],
101+
['IMAGE()', '_xlfn.IMAGE()'],
101102
['IMCOT()', '_xlfn.IMCOT()'],
102103
['IMCSC()', '_xlfn.IMCSC()'],
103104
['IMSEC()', '_xlfn.IMSEC()'],

0 commit comments

Comments
 (0)