line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Spreadsheet::HTML::Engine; |
2
|
5
|
|
|
5
|
|
18
|
use strict; |
|
5
|
|
|
|
|
5
|
|
|
5
|
|
|
|
|
121
|
|
3
|
5
|
|
|
5
|
|
15
|
use warnings FATAL => 'all'; |
|
5
|
|
|
|
|
5
|
|
|
5
|
|
|
|
|
1598
|
|
4
|
|
|
|
|
|
|
|
5
|
5
|
|
|
5
|
|
785
|
eval "use Spreadsheet::Engine"; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $NO_ENGINE = $@; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub _apply { |
9
|
0
|
0
|
|
0
|
|
|
return $_[0] if $NO_ENGINE; |
10
|
0
|
|
|
|
|
|
my ($data,$formula) = @_; |
11
|
0
|
0
|
|
|
|
|
$formula = [ $formula ] unless ref $formula; |
12
|
0
|
|
|
|
|
|
my $sheet = _import( $data ); |
13
|
0
|
|
|
|
|
|
$sheet->execute( $_ ) for @$formula; |
14
|
0
|
|
|
|
|
|
$sheet->recalc; |
15
|
0
|
|
|
|
|
|
return _export( $sheet ); |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub _import { |
19
|
0
|
|
|
0
|
|
|
my $data = shift; |
20
|
0
|
|
|
|
|
|
my $sheet = Spreadsheet::Engine->new; |
21
|
0
|
|
|
|
|
|
for my $row (0 .. $#$data) { |
22
|
0
|
|
|
|
|
|
for my $col (0 .. $#{ $data->[$row] }) { |
|
0
|
|
|
|
|
|
|
23
|
0
|
|
|
|
|
|
my $key = Spreadsheet::Engine::Sheet::number_to_col( $col + 1 ) . ( $row + 1 ); |
24
|
0
|
|
|
|
|
|
my $val = $data->[$row][$col]; |
25
|
0
|
0
|
|
|
|
|
my $type = $val =~ /\D/ ? 'v' : 'n'; |
26
|
0
|
|
|
|
|
|
$sheet->execute( "set $key value $type $val" ); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
} |
29
|
0
|
|
|
|
|
|
return $sheet; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub _export { |
33
|
0
|
|
|
0
|
|
|
my $sheet = shift; |
34
|
0
|
|
|
|
|
|
my @data; |
35
|
0
|
|
|
|
|
|
for my $row (0 .. $sheet->raw->{sheetattribs}{lastrow} - 1) { |
36
|
0
|
|
|
|
|
|
my @tmp; |
37
|
0
|
|
|
|
|
|
for my $col (0 .. $sheet->raw->{sheetattribs}{lastcol} - 1) { |
38
|
0
|
|
|
|
|
|
my $key = Spreadsheet::Engine::Sheet::number_to_col( $col + 1 ) . ( $row + 1 ); |
39
|
0
|
|
|
|
|
|
push @tmp, $sheet->raw->{datavalues}{$key}; |
40
|
|
|
|
|
|
|
} |
41
|
0
|
|
|
|
|
|
push @data, [@tmp]; |
42
|
0
|
|
|
|
|
|
@tmp = (); |
43
|
|
|
|
|
|
|
} |
44
|
0
|
|
|
|
|
|
return \@data; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 NAME |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
Spreadsheet::HTML::Engine - interface to Spreadsheet::Engine |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 DESCRIPTION |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
This is a container for L. This |
54
|
|
|
|
|
|
|
package is not meant to be directly used. Instead, |
55
|
|
|
|
|
|
|
use the Spreadsheet::HTML interface: |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
use Spreadsheet::HTML; |
58
|
|
|
|
|
|
|
my $generator = Spreadsheet::HTML->new( apply => 'set B6 formula SUM(B2:B5)' ); |
59
|
|
|
|
|
|
|
print $generator->generate(); |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
# or |
62
|
|
|
|
|
|
|
use Spreadsheet::HTML qw( generate ); |
63
|
|
|
|
|
|
|
print generate( apply => 'set B6 formula SUM(B2:B5)' ); |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 SEE ALSO |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=over 4 |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=item * L |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
The interface for this functionality. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=item * L |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
The engine that provides this functionality. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=back |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 AUTHOR |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Jeff Anderson, C<< >> |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Copyright 2017 Jeff Anderson. |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
88
|
|
|
|
|
|
|
under the terms of the the Artistic License (2.0). You may obtain a |
89
|
|
|
|
|
|
|
copy of the full license at: |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
L |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Any use, modification, and distribution of the Standard or Modified |
94
|
|
|
|
|
|
|
Versions is governed by this Artistic License. By using, modifying or |
95
|
|
|
|
|
|
|
distributing the Package, you accept this license. Do not use, modify, |
96
|
|
|
|
|
|
|
or distribute the Package, if you do not accept this license. |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
If your Modified Version has been derived from a Modified Version made |
99
|
|
|
|
|
|
|
by someone other than you, you are nevertheless required to ensure that |
100
|
|
|
|
|
|
|
your Modified Version complies with the requirements of this license. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
This license does not grant you the right to use any trademark, service |
103
|
|
|
|
|
|
|
mark, tradename, or logo of the Copyright Holder. |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
This license includes the non-exclusive, worldwide, free-of-charge |
106
|
|
|
|
|
|
|
patent license to make, have made, use, offer to sell, sell, import and |
107
|
|
|
|
|
|
|
otherwise transfer the Package with respect to any patent claims |
108
|
|
|
|
|
|
|
licensable by the Copyright Holder that are necessarily infringed by the |
109
|
|
|
|
|
|
|
Package. If you institute patent litigation (including a cross-claim or |
110
|
|
|
|
|
|
|
counterclaim) against any party alleging that the Package constitutes |
111
|
|
|
|
|
|
|
direct or contributory patent infringement, then this Artistic License |
112
|
|
|
|
|
|
|
to you shall terminate on the date that such litigation is filed. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER |
115
|
|
|
|
|
|
|
AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. |
116
|
|
|
|
|
|
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR |
117
|
|
|
|
|
|
|
PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY |
118
|
|
|
|
|
|
|
YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR |
119
|
|
|
|
|
|
|
CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR |
120
|
|
|
|
|
|
|
CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, |
121
|
|
|
|
|
|
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=cut |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
1; |