56 |
my $f = $format; |
my $f = $format; |
57 |
|
|
58 |
my $eval; |
my $eval; |
59 |
$eval = $1 if ($f =~ s/^eval{([^}]+)}//); |
$eval = $1 if ($f =~ s/^eval{([^}]+?)}//); |
60 |
|
|
61 |
if ($f =~ s/^([^\d]+)//) { |
if ($f =~ s/^([^\d]+)//) { |
62 |
if ($f) { # there is more to parse |
if ($f) { # there is more to parse |
163 |
sub fld2str { |
sub fld2str { |
164 |
my ($func,$row,$f,$sf,$i) = @_; |
my ($func,$row,$f,$sf,$i) = @_; |
165 |
#print STDERR "## in fld2str\n"; |
#print STDERR "## in fld2str\n"; |
166 |
my $tmp = $codepage->convert(&$func($row,$f,$sf,$i)) || ''; |
my $tmp = $codepage->convert(&$func($row,$f,$sf,$i)) || $codepage->convert(&$func($row,$f,$sf,0)) || ''; |
167 |
return "'$tmp'"; |
return "'$tmp'"; |
168 |
} |
} |
169 |
|
|
170 |
$eval =~ s/v(\d+)\^(\w*)/fld2str($func,$row,$1,$2,$i)/eg; |
$eval =~ s/v(\d+)\^(\w*)/fld2str($func,$row,$1,$2,$i)/eg; |
171 |
#print STDERR "## eval: $eval\n"; |
#print STDERR "## eval: $eval\n"; |
172 |
if (eval "$eval") { |
if (eval "$eval") { |
173 |
|
die "eval error: eval{$eval}: $@" if ($@); |
174 |
return ($swish,$display); |
return ($swish,$display); |
175 |
} else { |
} else { |
176 |
|
die "eval error: eval{$eval}: $@" if ($@); |
177 |
return (undef,undef); |
return (undef,undef); |
178 |
} |
} |
179 |
} |
} |
194 |
my $format = shift; |
my $format = shift; |
195 |
my $row = shift; |
my $row = shift; |
196 |
my $i = shift; |
my $i = shift; |
197 |
my $codepage = shift; |
#my $codepage = shift; |
198 |
|
# |
199 |
|
# data allready comes in utf-8 due to change in |
200 |
|
# SpreadSheet::ParseExcel::FmtDefault line 69 from |
201 |
|
# return pack('C*', unpack('n*', $sTxt)); |
202 |
|
# to following which returns utf-8: |
203 |
|
# return pack('U*', unpack('n*', $sTxt)); |
204 |
|
# |
205 |
|
|
206 |
return if ($i > 0); # Excel doesn't support repeatable fields |
return if ($i > 0); # Excel doesn't support repeatable fields |
207 |
|
|
222 |
#print STDERR "--$1-> $format -[",length($format),"] "; |
#print STDERR "--$1-> $format -[",length($format),"] "; |
223 |
if ($row->{$1}) { |
if ($row->{$1}) { |
224 |
my $tmp = $row->{$1}; |
my $tmp = $row->{$1}; |
|
if ($codepage) { |
|
|
$tmp = $codepage->convert($tmp) || warn "excel: $1 '$tmp' can't convert"; |
|
|
} |
|
225 |
$display .= $prefix . $tmp; |
$display .= $prefix . $tmp; |
226 |
$swish .= $tmp." "; |
$swish .= $tmp." "; |
227 |
#print STDERR " == $tmp"; |
#print STDERR " == $tmp"; |