Skip Menu |

This queue is for tickets about the Spreadsheet-XLSX CPAN distribution.

Report information
The Basics
Id: 132420
Status: new
Priority: 0/
Queue: Spreadsheet-XLSX

People
Owner: Nobody in particular
Requestors: mdoemling [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Fix for formatCode being lost
Date: Fri, 24 Apr 2020 15:37:55 -0700
To: bug-Spreadsheet-XLSX [...] rt.cpan.org
From: Marcus Doemling <mdoemling [...] gmail.com>
I ran into an issue where the formatCode was overwritten with an empty value in XLSX.pm. The fix was in __load_styles to add an existence check into the loop over @styles: --- XLSX.pm.orig    2020-04-24 21:07:50.027756593 +0000 +++ XLSX.pm    2020-04-24 22:31:25.438635988 +0000 @@ -225,6 +225,7 @@ sub __load_styles {          my $default = $1 || '';          foreach my $t1 (@styles) { +            if (!exists($style_info{$t1})) {              $member_styles->contents =~ /numFmtId="$t1" formatCode="([^"]*)/;              my $formatCode = $1 || '';              if ($formatCode eq $default || not($formatCode)) { @@ -240,6 +241,7 @@ sub __load_styles {              $style_info{$t1} = $formatCode;              $default = $1 || '';          } +        }      }      return (\@styles, \%style_info); The issue occurred with an .xlsx file with the following definitions:     <numFmts count="1">         <numFmt numFmtId="164" formatCode="00000" />     </numFmts>     <cellXfs count="14">         <xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0" />         <xf numFmtId="164" fontId="16" fillId="0" borderId="0" xfId="0" applyNumberFormat="1" applyFont="1" />         <xf numFmtId="164" fontId="0" fillId="0" borderId="0" xfId="0" applyNumberFormat="1" />         <xf numFmtId="164" fontId="0" fillId="0" borderId="0" xfId="0" applyNumberFormat="1" applyAlignment="1">         ...     </cellXfs> Ultimately the $formatCode was being overwritten due to $default being set. I was unsure what the purpose of $default was so my fix was to use the existence check. Hopefully you can apply this fix. Best, Marcus