| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# This code is adapted for Excel 2007 from: |
|
2
|
|
|
|
|
|
|
# Spreadsheet::XLSX::FmtDefault |
|
3
|
|
|
|
|
|
|
# by Kawai, Takanori (Hippo2000) 2001.2.2 |
|
4
|
|
|
|
|
|
|
# This Program is ALPHA version. |
|
5
|
|
|
|
|
|
|
#============================================================================== |
|
6
|
|
|
|
|
|
|
package Spreadsheet::XLSX::Fmt2007; |
|
7
|
7
|
|
|
7
|
|
57
|
use strict; |
|
|
7
|
|
|
|
|
15
|
|
|
|
7
|
|
|
|
|
233
|
|
|
8
|
7
|
|
|
7
|
|
39
|
use warnings; |
|
|
7
|
|
|
|
|
15
|
|
|
|
7
|
|
|
|
|
219
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
7
|
|
|
7
|
|
3917
|
use Spreadsheet::XLSX::Utility2007 qw(ExcelFmt); |
|
|
7
|
|
|
|
|
20
|
|
|
|
7
|
|
|
|
|
4852
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '0.17'; # |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my %hFmtDefault = ( |
|
14
|
|
|
|
|
|
|
0x00 => '@', |
|
15
|
|
|
|
|
|
|
0x01 => '0', |
|
16
|
|
|
|
|
|
|
0x02 => '0.00', |
|
17
|
|
|
|
|
|
|
0x03 => '#,##0', |
|
18
|
|
|
|
|
|
|
0x04 => '#,##0.00', |
|
19
|
|
|
|
|
|
|
0x05 => '($#,##0_);($#,##0)', |
|
20
|
|
|
|
|
|
|
0x06 => '($#,##0_);[RED]($#,##0)', |
|
21
|
|
|
|
|
|
|
0x07 => '($#,##0.00_);($#,##0.00_)', |
|
22
|
|
|
|
|
|
|
0x08 => '($#,##0.00_);[RED]($#,##0.00_)', |
|
23
|
|
|
|
|
|
|
0x09 => '0%', |
|
24
|
|
|
|
|
|
|
0x0A => '0.00%', |
|
25
|
|
|
|
|
|
|
0x0B => '0.00E+00', |
|
26
|
|
|
|
|
|
|
0x0C => '# ?/?', |
|
27
|
|
|
|
|
|
|
0x0D => '# ??/??', |
|
28
|
|
|
|
|
|
|
0x0E => 'yyyy-mm-dd', |
|
29
|
|
|
|
|
|
|
0x0F => 'd-mmm-yy', |
|
30
|
|
|
|
|
|
|
0x10 => 'd-mmm', |
|
31
|
|
|
|
|
|
|
0x11 => 'mmm-yy', |
|
32
|
|
|
|
|
|
|
0x12 => 'h:mm AM/PM', |
|
33
|
|
|
|
|
|
|
0x13 => 'h:mm:ss AM/PM', |
|
34
|
|
|
|
|
|
|
0x14 => 'h:mm', |
|
35
|
|
|
|
|
|
|
0x15 => 'h:mm:ss', |
|
36
|
|
|
|
|
|
|
0x16 => 'm-d-yy h:mm', |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
#0x17-0x24 -- Differs in Natinal |
|
39
|
|
|
|
|
|
|
0x25 => '(#,##0_);(#,##0)', |
|
40
|
|
|
|
|
|
|
0x26 => '(#,##0_);[RED](#,##0)', |
|
41
|
|
|
|
|
|
|
0x27 => '(#,##0.00);(#,##0.00)', |
|
42
|
|
|
|
|
|
|
0x28 => '(#,##0.00);[RED](#,##0.00)', |
|
43
|
|
|
|
|
|
|
0x29 => '_(*#,##0_);_(*(#,##0);_(*"-"_);_(@_)', |
|
44
|
|
|
|
|
|
|
0x2A => '_($*#,##0_);_($*(#,##0);_(*"-"_);_(@_)', |
|
45
|
|
|
|
|
|
|
0x2B => '_(*#,##0.00_);_(*(#,##0.00);_(*"-"??_);_(@_)', |
|
46
|
|
|
|
|
|
|
0x2C => '_($*#,##0.00_);_($*(#,##0.00);_(*"-"??_);_(@_)', |
|
47
|
|
|
|
|
|
|
0x2D => 'mm:ss', |
|
48
|
|
|
|
|
|
|
0x2E => '[h]:mm:ss', |
|
49
|
|
|
|
|
|
|
0x2F => 'mm:ss.0', |
|
50
|
|
|
|
|
|
|
0x30 => '##0.0E+0', |
|
51
|
|
|
|
|
|
|
0x31 => '@', |
|
52
|
|
|
|
|
|
|
); |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
|
55
|
|
|
|
|
|
|
# new (for Spreadsheet::XLSX::Utility2007) |
|
56
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
|
57
|
|
|
|
|
|
|
sub new { |
|
58
|
10
|
|
|
10
|
0
|
25
|
my ($sPkg, %hKey) = @_; |
|
59
|
10
|
|
|
|
|
19
|
my $oThis = {}; |
|
60
|
10
|
|
|
|
|
22
|
bless $oThis; |
|
61
|
10
|
|
|
|
|
38
|
return $oThis; |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
|
65
|
|
|
|
|
|
|
# TextFmt (for Spreadsheet::XLSX::Utility2007) |
|
66
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
|
67
|
|
|
|
|
|
|
sub TextFmt { |
|
68
|
836
|
|
|
836
|
0
|
2277
|
my ($oThis, $sTxt, $sCode) = @_; |
|
69
|
836
|
50
|
33
|
|
|
2941
|
return $sTxt if ((!defined($sCode)) || ($sCode eq '_native_')); |
|
70
|
0
|
|
|
|
|
0
|
return pack('U*', unpack('n*', $sTxt)); |
|
71
|
|
|
|
|
|
|
} |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
|
74
|
|
|
|
|
|
|
# FmtStringDef (for Spreadsheet::XLSX::Utility2007) |
|
75
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
|
76
|
|
|
|
|
|
|
sub FmtStringDef { |
|
77
|
0
|
|
|
0
|
0
|
0
|
my ($oThis, $iFmtIdx, $oBook, $rhFmt) = @_; |
|
78
|
0
|
|
|
|
|
0
|
my $sFmtStr = $oBook->{FormatStr}->{$iFmtIdx}; |
|
79
|
|
|
|
|
|
|
|
|
80
|
0
|
0
|
0
|
|
|
0
|
if (!(defined($sFmtStr)) && defined($rhFmt)) { |
|
81
|
0
|
|
|
|
|
0
|
$sFmtStr = $rhFmt->{$iFmtIdx}; |
|
82
|
|
|
|
|
|
|
} |
|
83
|
0
|
0
|
|
|
|
0
|
$sFmtStr = $hFmtDefault{$iFmtIdx} unless ($sFmtStr); |
|
84
|
0
|
|
|
|
|
0
|
return $sFmtStr; |
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
|
88
|
|
|
|
|
|
|
# FmtString (for Spreadsheet::XLSX::Utility2007) |
|
89
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
|
90
|
|
|
|
|
|
|
sub FmtString { |
|
91
|
1622
|
|
|
1622
|
0
|
2628
|
my ($oThis, $oCell, $oBook) = @_; |
|
92
|
|
|
|
|
|
|
|
|
93
|
1622
|
|
|
|
|
2245
|
my $sFmtStr; # = $oThis->FmtStringDef( |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
# $oBook->{Format}[$oCell->{FormatNo}]->{FmtIdx}, $oBook); |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
# Check for formula error before evaluating format |
|
98
|
1622
|
50
|
|
|
|
4091
|
return '@' if ( $oCell->{Val} =~ m/^#/ ); |
|
99
|
|
|
|
|
|
|
|
|
100
|
1622
|
50
|
|
|
|
3105
|
unless (defined($sFmtStr)) { |
|
101
|
1622
|
100
|
|
|
|
4124
|
if ($oCell->{Type} eq 'Numeric') { |
|
|
|
100
|
|
|
|
|
|
|
102
|
784
|
100
|
|
|
|
2200
|
if ($oCell->{Format}) { |
|
|
|
100
|
|
|
|
|
|
|
103
|
395
|
|
|
|
|
751
|
$sFmtStr = $oCell->{Format}; |
|
104
|
|
|
|
|
|
|
} elsif (int($oCell->{Val}) != $oCell->{Val}) { |
|
105
|
242
|
|
|
|
|
467
|
$sFmtStr = '0.00'; |
|
106
|
|
|
|
|
|
|
} else { |
|
107
|
147
|
|
|
|
|
229
|
$sFmtStr = '0'; |
|
108
|
|
|
|
|
|
|
} |
|
109
|
|
|
|
|
|
|
} elsif ($oCell->{Type} eq 'Date') { |
|
110
|
2
|
50
|
|
|
|
3
|
if ($oCell->{Format}) { |
|
|
|
0
|
|
|
|
|
|
|
111
|
2
|
|
|
|
|
5
|
$sFmtStr = $oCell->{Format}; |
|
112
|
|
|
|
|
|
|
} elsif (int($oCell->{Val}) <= 0) { |
|
113
|
0
|
|
|
|
|
0
|
$sFmtStr = 'h:mm:ss'; |
|
114
|
|
|
|
|
|
|
} else { |
|
115
|
0
|
|
|
|
|
0
|
$sFmtStr = 'm-d-yy'; |
|
116
|
|
|
|
|
|
|
} |
|
117
|
|
|
|
|
|
|
} else { |
|
118
|
836
|
|
|
|
|
1285
|
$sFmtStr = '@'; |
|
119
|
|
|
|
|
|
|
} |
|
120
|
|
|
|
|
|
|
} |
|
121
|
1622
|
|
|
|
|
3492
|
return $sFmtStr; |
|
122
|
|
|
|
|
|
|
} |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
|
125
|
|
|
|
|
|
|
# ValFmt (for Spreadsheet::XLSX::Utility2007) |
|
126
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
|
127
|
|
|
|
|
|
|
sub ValFmt { |
|
128
|
1622
|
|
|
1622
|
0
|
3700
|
my ($oThis, $oCell, $oBook) = @_; |
|
129
|
|
|
|
|
|
|
|
|
130
|
1622
|
|
|
|
|
2565
|
my ($Dt, $iFmtIdx, $iNumeric, $Flg1904); |
|
131
|
|
|
|
|
|
|
|
|
132
|
1622
|
100
|
|
|
|
3223
|
if ($oCell->{Type} eq 'Text') { |
|
133
|
836
|
50
|
33
|
|
|
4256
|
$Dt = ((defined $oCell->{Val}) && ($oCell->{Val} ne '')) ? $oThis->TextFmt($oCell->{Val}, $oCell->{Code}) : ''; |
|
134
|
|
|
|
|
|
|
} else { |
|
135
|
786
|
|
|
|
|
1344
|
$Dt = $oCell->{Val}; |
|
136
|
|
|
|
|
|
|
} |
|
137
|
1622
|
|
|
|
|
3081
|
$Flg1904 = $oBook->{Flg1904}; |
|
138
|
1622
|
|
|
|
|
3112
|
my $sFmtStr = $oThis->FmtString($oCell, $oBook); |
|
139
|
1622
|
|
|
|
|
4306
|
return ExcelFmt($sFmtStr, $Dt, $Flg1904, $oCell->{Type}); |
|
140
|
|
|
|
|
|
|
} |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
|
143
|
|
|
|
|
|
|
# ChkType (for Spreadsheet::XLSX::Utility2007) |
|
144
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
|
145
|
|
|
|
|
|
|
sub ChkType { |
|
146
|
0
|
|
|
0
|
0
|
|
my ($oPkg, $iNumeric, $iFmtIdx) = @_; |
|
147
|
0
|
0
|
|
|
|
|
if ($iNumeric) { |
|
148
|
0
|
0
|
0
|
|
|
|
if ( (($iFmtIdx >= 0x0E) && ($iFmtIdx <= 0x16)) |
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
149
|
|
|
|
|
|
|
|| (($iFmtIdx >= 0x2D) && ($iFmtIdx <= 0x2F))) { |
|
150
|
0
|
|
|
|
|
|
return "Date"; |
|
151
|
|
|
|
|
|
|
} else { |
|
152
|
0
|
|
|
|
|
|
return "Numeric"; |
|
153
|
|
|
|
|
|
|
} |
|
154
|
|
|
|
|
|
|
} else { |
|
155
|
0
|
|
|
|
|
|
return "Text"; |
|
156
|
|
|
|
|
|
|
} |
|
157
|
|
|
|
|
|
|
} |
|
158
|
|
|
|
|
|
|
1; |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
__END__ |