← Index
NYTProf Performance Profile   « line view »
For t/bug-md-11.t
  Run on Fri Mar 8 13:27:24 2024
Reported on Fri Mar 8 13:30:23 2024

Filename/home/micha/.plenv/versions/5.38.2/lib/perl5/site_perl/5.38.2/Spreadsheet/ParseExcel/FmtDefault.pm
StatementsExecuted 1269100 statements in 1.21s
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
20290711682ms810msSpreadsheet::ParseExcel::FmtDefault::::ValFmtSpreadsheet::ParseExcel::FmtDefault::ValFmt
12727611128ms128msSpreadsheet::ParseExcel::FmtDefault::::TextFmtSpreadsheet::ParseExcel::FmtDefault::TextFmt
1113.26ms3.33msSpreadsheet::ParseExcel::FmtDefault::::BEGIN@22Spreadsheet::ParseExcel::FmtDefault::BEGIN@22
11113µs14µsSpreadsheet::ParseExcel::FmtDefault::::BEGIN@19Spreadsheet::ParseExcel::FmtDefault::BEGIN@19
1113µs18µsSpreadsheet::ParseExcel::FmtDefault::::BEGIN@20Spreadsheet::ParseExcel::FmtDefault::BEGIN@20
1113µs3µsSpreadsheet::ParseExcel::FmtDefault::::newSpreadsheet::ParseExcel::FmtDefault::new
0000s0sSpreadsheet::ParseExcel::FmtDefault::::ChkTypeSpreadsheet::ParseExcel::FmtDefault::ChkType
0000s0sSpreadsheet::ParseExcel::FmtDefault::::FmtStringSpreadsheet::ParseExcel::FmtDefault::FmtString
0000s0sSpreadsheet::ParseExcel::FmtDefault::::FmtStringDefSpreadsheet::ParseExcel::FmtDefault::FmtStringDef
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Spreadsheet::ParseExcel::FmtDefault;
2
3###############################################################################
4#
5# Spreadsheet::ParseExcel::FmtDefault - A class for Cell formats.
6#
7# Used in conjunction with Spreadsheet::ParseExcel.
8#
9# Copyright (c) 2014 Douglas Wilson
10# Copyright (c) 2009-2013 John McNamara
11# Copyright (c) 2006-2008 Gabor Szabo
12# Copyright (c) 2000-2006 Kawai Takanori
13#
14# perltidy with standard settings.
15#
16# Documentation after __END__
17#
18
19222µs216µs
# spent 14µs (13+1) within Spreadsheet::ParseExcel::FmtDefault::BEGIN@19 which was called: # once (13µs+1µs) by Spreadsheet::ParseExcel::BEGIN@36 at line 19
use strict;
# spent 14µs making 1 call to Spreadsheet::ParseExcel::FmtDefault::BEGIN@19 # spent 1µs making 1 call to strict::import
20216µs233µs
# spent 18µs (3+15) within Spreadsheet::ParseExcel::FmtDefault::BEGIN@20 which was called: # once (3µs+15µs) by Spreadsheet::ParseExcel::BEGIN@36 at line 20
use warnings;
# spent 18µs making 1 call to Spreadsheet::ParseExcel::FmtDefault::BEGIN@20 # spent 15µs making 1 call to warnings::import
21
222412µs23.35ms
# spent 3.33ms (3.26+74µs) within Spreadsheet::ParseExcel::FmtDefault::BEGIN@22 which was called: # once (3.26ms+74µs) by Spreadsheet::ParseExcel::BEGIN@36 at line 22
use Spreadsheet::ParseExcel::Utility qw(ExcelFmt);
# spent 3.33ms making 1 call to Spreadsheet::ParseExcel::FmtDefault::BEGIN@22 # spent 26µs making 1 call to Exporter::import
231300nsour $VERSION = '0.66';
24
25111µsmy %hFmtDefault = (
26 0x00 => 'General',
27 0x01 => '0',
28 0x02 => '0.00',
29 0x03 => '#,##0',
30 0x04 => '#,##0.00',
31 0x05 => '($#,##0_);($#,##0)',
32 0x06 => '($#,##0_);[Red]($#,##0)',
33 0x07 => '($#,##0.00_);($#,##0.00_)',
34 0x08 => '($#,##0.00_);[Red]($#,##0.00_)',
35 0x09 => '0%',
36 0x0A => '0.00%',
37 0x0B => '0.00E+00',
38 0x0C => '# ?/?',
39 0x0D => '# ??/??',
40 0x0E => 'yyyy-mm-dd', # Was 'm-d-yy', which is bad as system default
41 0x0F => 'd-mmm-yy',
42 0x10 => 'd-mmm',
43 0x11 => 'mmm-yy',
44 0x12 => 'h:mm AM/PM',
45 0x13 => 'h:mm:ss AM/PM',
46 0x14 => 'h:mm',
47 0x15 => 'h:mm:ss',
48 0x16 => 'm-d-yy h:mm',
49
50 #0x17-0x24 -- Differs in Natinal
51 0x25 => '(#,##0_);(#,##0)',
52 0x26 => '(#,##0_);[Red](#,##0)',
53 0x27 => '(#,##0.00);(#,##0.00)',
54 0x28 => '(#,##0.00);[Red](#,##0.00)',
55 0x29 => '_(*#,##0_);_(*(#,##0);_(*"-"_);_(@_)',
56 0x2A => '_($*#,##0_);_($*(#,##0);_(*"-"_);_(@_)',
57 0x2B => '_(*#,##0.00_);_(*(#,##0.00);_(*"-"??_);_(@_)',
58 0x2C => '_($*#,##0.00_);_($*(#,##0.00);_(*"-"??_);_(@_)',
59 0x2D => 'mm:ss',
60 0x2E => '[h]:mm:ss',
61 0x2F => 'mm:ss.0',
62 0x30 => '##0.0E+0',
63 0x31 => '@',
64);
65
66#------------------------------------------------------------------------------
67# new (for Spreadsheet::ParseExcel::FmtDefault)
68#------------------------------------------------------------------------------
69
# spent 3µs within Spreadsheet::ParseExcel::FmtDefault::new which was called: # once (3µs+0s) by Spreadsheet::ParseXLSX::_parse_workbook at line 151 of /home/micha/Projekt/spreadsheet-parsexlsx/lib/Spreadsheet/ParseXLSX.pm
sub new {
701700ns my ( $sPkg, %hKey ) = @_;
711300ns my $oThis = {};
721400ns bless $oThis;
7312µs return $oThis;
74}
75
76#------------------------------------------------------------------------------
77# TextFmt (for Spreadsheet::ParseExcel::FmtDefault)
78#------------------------------------------------------------------------------
79
# spent 128ms within Spreadsheet::ParseExcel::FmtDefault::TextFmt which was called 127276 times, avg 1µs/call: # 127276 times (128ms+0s) by Spreadsheet::ParseExcel::FmtDefault::ValFmt at line 151, avg 1µs/call
sub TextFmt {
8012727664.3ms my ( $oThis, $sTxt, $sCode ) = @_;
81127276352ms return $sTxt if ( ( !defined($sCode) ) || ( $sCode eq '_native_' ) );
82 return pack( 'U*', unpack( 'n*', $sTxt ) );
83}
84
85#------------------------------------------------------------------------------
86# FmtStringDef (for Spreadsheet::ParseExcel::FmtDefault)
87#------------------------------------------------------------------------------
88sub FmtStringDef {
89 my ( $oThis, $iFmtIdx, $oBook, $rhFmt ) = @_;
90 my $sFmtStr = $oBook->{FormatStr}->{$iFmtIdx};
91
92 if ( !( defined($sFmtStr) ) && defined($rhFmt) ) {
93 $sFmtStr = $rhFmt->{$iFmtIdx};
94 }
95 $sFmtStr = $hFmtDefault{$iFmtIdx} unless ($sFmtStr);
96 return $sFmtStr;
97}
98
99#------------------------------------------------------------------------------
100# FmtString (for Spreadsheet::ParseExcel::FmtDefault)
101#------------------------------------------------------------------------------
102sub FmtString {
103 my ( $oThis, $oCell, $oBook ) = @_;
104
105 my $sFmtStr =
106 $oThis->FmtStringDef( $oBook->{Format}[ $oCell->{FormatNo} ]->{FmtIdx},
107 $oBook );
108
109 # Special case for cells that use Lotus123 style leading
110 # apostrophe to designate text formatting.
111 if ( $oBook->{Format}[ $oCell->{FormatNo} ]->{Key123} ) {
112 $sFmtStr = '@';
113 }
114
115 unless ( defined($sFmtStr) ) {
116 if ( $oCell->{Type} eq 'Numeric' ) {
117 if ( int( $oCell->{Val} ) != $oCell->{Val} ) {
118 $sFmtStr = '0.00';
119 }
120 else {
121 $sFmtStr = '0';
122 }
123 }
124 elsif ( $oCell->{Type} eq 'Date' ) {
125 if ( int( $oCell->{Val} ) <= 0 ) {
126 $sFmtStr = 'h:mm:ss';
127 }
128 else {
129 $sFmtStr = 'yyyy-mm-dd';
130 }
131 }
132 else {
133 $sFmtStr = '@';
134 }
135 }
136 return $sFmtStr;
137}
138
139#------------------------------------------------------------------------------
140# ValFmt (for Spreadsheet::ParseExcel::FmtDefault)
141#------------------------------------------------------------------------------
142
# spent 810ms (682+128) within Spreadsheet::ParseExcel::FmtDefault::ValFmt which was called 202907 times, avg 4µs/call: # 202907 times (682ms+128ms) by Spreadsheet::ParseXLSX::__ANON__[lib/Spreadsheet/ParseXLSX.pm:443] at line 436 of /home/micha/Projekt/spreadsheet-parsexlsx/lib/Spreadsheet/ParseXLSX.pm, avg 4µs/call
sub ValFmt {
14320290726.4ms my ( $oThis, $oCell, $oBook ) = @_;
144
14520290715.0ms my ( $Dt, $iFmtIdx, $iNumeric, $Flg1904 );
146
14720290747.6ms if ( $oCell->{Type} eq 'Text' ) {
148 $Dt =
149 ( ( defined $oCell->{Val} ) && ( $oCell->{Val} ne '' ) )
150 ? $oThis->TextFmt( $oCell->{Val}, $oCell->{Code} )
151202907198ms127276128ms : '';
# spent 128ms making 127276 calls to Spreadsheet::ParseExcel::FmtDefault::TextFmt, avg 1µs/call
152
153202907508ms return $Dt;
154 }
155 else {
156 $Dt = $oCell->{Val};
157 $Flg1904 = $oBook->{Flg1904};
158 my $sFmtStr = $oThis->FmtString( $oCell, $oBook );
159
160 return ExcelFmt( $sFmtStr, $Dt, $Flg1904, $oCell->{Type} );
161 }
162}
163
164#------------------------------------------------------------------------------
165# ChkType (for Spreadsheet::ParseExcel::FmtDefault)
166#------------------------------------------------------------------------------
167sub ChkType {
168 my ( $oPkg, $iNumeric, $iFmtIdx ) = @_;
169 if ($iNumeric) {
170 if ( ( ( $iFmtIdx >= 0x0E ) && ( $iFmtIdx <= 0x16 ) )
171 || ( ( $iFmtIdx >= 0x2D ) && ( $iFmtIdx <= 0x2F ) ) )
172 {
173 return "Date";
174 }
175 else {
176 return "Numeric";
177 }
178 }
179 else {
180 return "Text";
181 }
182}
183
18415µs1;
185
186__END__