Skip to content

Commit

Permalink
worksheet: add support for IMAGE() future function
Browse files Browse the repository at this point in the history
Issue #293
  • Loading branch information
jmcnamara committed Feb 17, 2024
1 parent 24563bc commit a703853
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
13 changes: 13 additions & 0 deletions lib/Excel/Writer/XLSX.pm
Original file line number Diff line number Diff line change
Expand Up @@ -6624,6 +6624,7 @@ The following list is taken from the MS XLSX extensions documentation on future
_xlfn.ACOTH
_xlfn.AGGREGATE
_xlfn.ARABIC
_xlfn.ARRAYTOTEXT
_xlfn.BASE
_xlfn.BETA.DIST
_xlfn.BETA.INV
Expand All @@ -6643,6 +6644,7 @@ The following list is taken from the MS XLSX extensions documentation on future
_xlfn.CHISQ.INV.RT
_xlfn.CHISQ.TEST
_xlfn.COMBINA
_xlfn.CONCAT
_xlfn.CONFIDENCE.NORM
_xlfn.CONFIDENCE.T
_xlfn.COT
Expand Down Expand Up @@ -6678,6 +6680,8 @@ The following list is taken from the MS XLSX extensions documentation on future
_xlfn.GAUSS
_xlfn.HYPGEOM.DIST
_xlfn.IFNA
_xlfn.IFS
_xlfn.IMAGE
_xlfn.IMCOSH
_xlfn.IMCOT
_xlfn.IMCSC
Expand All @@ -6688,9 +6692,13 @@ The following list is taken from the MS XLSX extensions documentation on future
_xlfn.IMTAN
_xlfn.ISFORMULA
ISO.CEILING
_xlfn.ISOMITTED
_xlfn.ISOWEEKNUM
_xlfn.LET
_xlfn.LOGNORM.DIST
_xlfn.LOGNORM.INV
_xlfn.MAXIFS
_xlfn.MINIFS
_xlfn.MODE.MULT
_xlfn.MODE.SNGL
_xlfn.MUNIT
Expand Down Expand Up @@ -6728,13 +6736,18 @@ The following list is taken from the MS XLSX extensions documentation on future
_xlfn.T.INV
_xlfn.T.INV.2T
_xlfn.T.TEST
_xlfn.TEXTAFTER
_xlfn.TEXTBEFORE
_xlfn.TEXTJOIN
_xlfn.UNICHAR
_xlfn.UNICODE
_xlfn.VALUETOTEXT
_xlfn.VAR.P
_xlfn.VAR.S
_xlfn.WEBSERVICE
_xlfn.WEIBULL.DIST
WORKDAY.INTL
_xlfn.XMATCH
_xlfn.XOR
_xlfn.Z.TEST
Expand Down
5 changes: 3 additions & 2 deletions lib/Excel/Writer/XLSX/Worksheet.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2935,6 +2935,7 @@ sub _prepare_formula {
$formula =~ s/\b(HYPGEOM.DIST\()/_xlfn.$1/g;
$formula =~ s/\b(IFNA\()/_xlfn.$1/g;
$formula =~ s/\b(IFS\()/_xlfn.$1/g;
$formula =~ s/\b(IMAGE\()/_xlfn.$1/g;
$formula =~ s/\b(IMCOSH\()/_xlfn.$1/g;
$formula =~ s/\b(IMCOT\()/_xlfn.$1/g;
$formula =~ s/\b(IMCSCH\()/_xlfn.$1/g;
Expand Down Expand Up @@ -3081,8 +3082,8 @@ sub write_formula {
# Check that row and col are valid and store max and min values
return -2 if $self->_check_dimensions( $row, $col );

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

# Write previous row if in in-line string optimization mode.
if ( $self->{_optimization} == 1 && $row > $self->{_previous_row} ) {
Expand Down
3 changes: 2 additions & 1 deletion t/worksheet/sub_prepare_formula.t
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use strict;
use warnings;
use Excel::Writer::XLSX::Worksheet;

use Test::More tests => 179;
use Test::More tests => 180;


###############################################################################
Expand Down Expand Up @@ -98,6 +98,7 @@ my @testcases = (
['F.INV()', '_xlfn.F.INV()'],
['GAMMA()', '_xlfn.GAMMA()'],
['GAUSS()', '_xlfn.GAUSS()'],
['IMAGE()', '_xlfn.IMAGE()'],
['IMCOT()', '_xlfn.IMCOT()'],
['IMCSC()', '_xlfn.IMCSC()'],
['IMSEC()', '_xlfn.IMSEC()'],
Expand Down

0 comments on commit a703853

Please sign in to comment.