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
|
6
|
|
|
6
|
|
32
|
use strict; |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
155
|
|
8
|
6
|
|
|
6
|
|
32
|
use warnings; |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
183
|
|
9
|
|
|
|
|
|
|
|
10
|
6
|
|
|
6
|
|
4374
|
use Spreadsheet::XLSX::Utility2007 qw(ExcelFmt); |
|
6
|
|
|
|
|
16
|
|
|
6
|
|
|
|
|
4115
|
|
11
|
|
|
|
|
|
|
our $VERSION = '0.13'; # |
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::FmtDefault) |
56
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
57
|
|
|
|
|
|
|
sub new { |
58
|
10
|
|
|
10
|
0
|
22
|
my ($sPkg, %hKey) = @_; |
59
|
10
|
|
|
|
|
21
|
my $oThis = {}; |
60
|
10
|
|
|
|
|
15
|
bless $oThis; |
61
|
10
|
|
|
|
|
32
|
return $oThis; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
65
|
|
|
|
|
|
|
# TextFmt (for Spreadsheet::XLSX::FmtDefault) |
66
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
67
|
|
|
|
|
|
|
sub TextFmt { |
68
|
836
|
|
|
836
|
0
|
1618
|
my ($oThis, $sTxt, $sCode) = @_; |
69
|
836
|
50
|
33
|
|
|
3165
|
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::FmtDefault) |
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::FmtDefault) |
89
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
90
|
|
|
|
|
|
|
sub FmtString { |
91
|
1622
|
|
|
1622
|
0
|
2446
|
my ($oThis, $oCell, $oBook) = @_; |
92
|
|
|
|
|
|
|
|
93
|
1622
|
|
|
|
|
1798
|
my $sFmtStr; # = $oThis->FmtStringDef( |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
# $oBook->{Format}[$oCell->{FormatNo}]->{FmtIdx}, $oBook); |
96
|
|
|
|
|
|
|
|
97
|
1622
|
50
|
|
|
|
3165
|
unless (defined($sFmtStr)) { |
98
|
1622
|
100
|
|
|
|
4018
|
if ($oCell->{Type} eq 'Numeric') { |
|
|
100
|
|
|
|
|
|
99
|
784
|
100
|
|
|
|
2286
|
if ($oCell->{Format}) { |
|
|
100
|
|
|
|
|
|
100
|
395
|
|
|
|
|
748
|
$sFmtStr = $oCell->{Format}; |
101
|
|
|
|
|
|
|
} elsif (int($oCell->{Val}) != $oCell->{Val}) { |
102
|
242
|
|
|
|
|
381
|
$sFmtStr = '0.00'; |
103
|
|
|
|
|
|
|
} else { |
104
|
147
|
|
|
|
|
214
|
$sFmtStr = '0'; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
} elsif ($oCell->{Type} eq 'Date') { |
107
|
2
|
50
|
|
|
|
6
|
if ($oCell->{Format}) { |
|
|
0
|
|
|
|
|
|
108
|
2
|
|
|
|
|
3
|
$sFmtStr = $oCell->{Format}; |
109
|
|
|
|
|
|
|
} elsif (int($oCell->{Val}) <= 0) { |
110
|
0
|
|
|
|
|
0
|
$sFmtStr = 'h:mm:ss'; |
111
|
|
|
|
|
|
|
} else { |
112
|
0
|
|
|
|
|
0
|
$sFmtStr = 'm-d-yy'; |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
} else { |
115
|
836
|
|
|
|
|
1277
|
$sFmtStr = '@'; |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
} |
118
|
1622
|
|
|
|
|
3603
|
return $sFmtStr; |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
122
|
|
|
|
|
|
|
# ValFmt (for Spreadsheet::XLSX::FmtDefault) |
123
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
124
|
|
|
|
|
|
|
sub ValFmt { |
125
|
1622
|
|
|
1622
|
0
|
2680
|
my ($oThis, $oCell, $oBook) = @_; |
126
|
|
|
|
|
|
|
|
127
|
1622
|
|
|
|
|
1866
|
my ($Dt, $iFmtIdx, $iNumeric, $Flg1904); |
128
|
|
|
|
|
|
|
|
129
|
1622
|
100
|
|
|
|
3517
|
if ($oCell->{Type} eq 'Text') { |
130
|
836
|
50
|
33
|
|
|
5039
|
$Dt = ((defined $oCell->{Val}) && ($oCell->{Val} ne '')) ? $oThis->TextFmt($oCell->{Val}, $oCell->{Code}) : ''; |
131
|
|
|
|
|
|
|
} else { |
132
|
786
|
|
|
|
|
1313
|
$Dt = $oCell->{Val}; |
133
|
|
|
|
|
|
|
} |
134
|
1622
|
|
|
|
|
2959
|
$Flg1904 = $oBook->{Flg1904}; |
135
|
1622
|
|
|
|
|
3084
|
my $sFmtStr = $oThis->FmtString($oCell, $oBook); |
136
|
1622
|
|
|
|
|
4714
|
return ExcelFmt($sFmtStr, $Dt, $Flg1904, $oCell->{Type}); |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
140
|
|
|
|
|
|
|
# ChkType (for Spreadsheet::XLSX::FmtDefault) |
141
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
142
|
|
|
|
|
|
|
sub ChkType { |
143
|
0
|
|
|
0
|
0
|
|
my ($oPkg, $iNumeric, $iFmtIdx) = @_; |
144
|
0
|
0
|
|
|
|
|
if ($iNumeric) { |
145
|
0
|
0
|
0
|
|
|
|
if ( (($iFmtIdx >= 0x0E) && ($iFmtIdx <= 0x16)) |
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
146
|
|
|
|
|
|
|
|| (($iFmtIdx >= 0x2D) && ($iFmtIdx <= 0x2F))) { |
147
|
0
|
|
|
|
|
|
return "Date"; |
148
|
|
|
|
|
|
|
} else { |
149
|
0
|
|
|
|
|
|
return "Numeric"; |
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
} else { |
152
|
0
|
|
|
|
|
|
return "Text"; |
153
|
|
|
|
|
|
|
} |
154
|
|
|
|
|
|
|
} |
155
|
|
|
|
|
|
|
1; |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
__END__ |