sp-excel-loader 0.3.40
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +4 -0
- data/LICENSE +661 -0
- data/README.md +8 -0
- data/lib/sp-excel-loader.rb +6 -0
- data/lib/sp/excel/loader.rb +61 -0
- data/lib/sp/excel/loader/jrxml/band.rb +80 -0
- data/lib/sp/excel/loader/jrxml/band_container.rb +229 -0
- data/lib/sp/excel/loader/jrxml/box.rb +75 -0
- data/lib/sp/excel/loader/jrxml/casper_checkbox.rb +97 -0
- data/lib/sp/excel/loader/jrxml/casper_combo.rb +86 -0
- data/lib/sp/excel/loader/jrxml/casper_date.rb +54 -0
- data/lib/sp/excel/loader/jrxml/casper_radio_button.rb +48 -0
- data/lib/sp/excel/loader/jrxml/casper_text_field.rb +157 -0
- data/lib/sp/excel/loader/jrxml/client_combo_text_field.rb +72 -0
- data/lib/sp/excel/loader/jrxml/excel_to_jrxml.rb +1183 -0
- data/lib/sp/excel/loader/jrxml/extensions.rb +330 -0
- data/lib/sp/excel/loader/jrxml/field.rb +65 -0
- data/lib/sp/excel/loader/jrxml/group.rb +71 -0
- data/lib/sp/excel/loader/jrxml/image.rb +63 -0
- data/lib/sp/excel/loader/jrxml/jasper.rb +228 -0
- data/lib/sp/excel/loader/jrxml/parameter.rb +73 -0
- data/lib/sp/excel/loader/jrxml/pen.rb +97 -0
- data/lib/sp/excel/loader/jrxml/property.rb +52 -0
- data/lib/sp/excel/loader/jrxml/property_expression.rb +52 -0
- data/lib/sp/excel/loader/jrxml/report_element.rb +92 -0
- data/lib/sp/excel/loader/jrxml/static_text.rb +59 -0
- data/lib/sp/excel/loader/jrxml/style.rb +99 -0
- data/lib/sp/excel/loader/jrxml/text_field.rb +83 -0
- data/lib/sp/excel/loader/jrxml/variable.rb +77 -0
- data/lib/sp/excel/loader/json_to_xlsx.rb +159 -0
- data/lib/sp/excel/loader/model_exporter.rb +249 -0
- data/lib/sp/excel/loader/payrollexporter.rb +168 -0
- data/lib/sp/excel/loader/rubyxl_table_patch.rb +91 -0
- data/lib/sp/excel/loader/version.rb +26 -0
- data/lib/sp/excel/loader/workbookloader.rb +480 -0
- data/spec/calc_spec.rb +87 -0
- data/spec/model.xls +0 -0
- metadata +151 -0
data/README.md
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
#
|
3
|
+
# Copyright (c) 2011-2016 Cloudware S.A. All rights reserved.
|
4
|
+
#
|
5
|
+
# This file is part of sp-excel-loader.
|
6
|
+
#
|
7
|
+
# sp-excel-loader is free software: you can redistribute it and/or modify
|
8
|
+
# it under the terms of the GNU Affero General Public License as published by
|
9
|
+
# the Free Software Foundation, either version 3 of the License, or
|
10
|
+
# (at your option) any later version.
|
11
|
+
#
|
12
|
+
# sp-excel-loader is distributed in the hope that it will be useful,
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
# GNU General Public License for more details.
|
16
|
+
#
|
17
|
+
# You should have received a copy of the GNU Affero General Public License
|
18
|
+
# along with sp-excel-loader. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
#
|
20
|
+
|
21
|
+
require 'rubyXL'
|
22
|
+
require 'json'
|
23
|
+
#require 'byebug'
|
24
|
+
|
25
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'loader', 'rubyxl_table_patch'))
|
26
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'loader', 'workbookloader'))
|
27
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'loader', 'model_exporter'))
|
28
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'loader', 'payrollexporter'))
|
29
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'loader', 'json_to_xlsx'))
|
30
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'loader', 'jrxml', 'excel_to_jrxml'))
|
31
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'loader', 'jrxml', 'style'))
|
32
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'loader', 'jrxml', 'pen'))
|
33
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'loader', 'jrxml', 'band'))
|
34
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'loader', 'jrxml', 'band_container'))
|
35
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'loader', 'jrxml', 'box'))
|
36
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'loader', 'jrxml', 'group'))
|
37
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'loader', 'jrxml', 'parameter'))
|
38
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'loader', 'jrxml', 'field'))
|
39
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'loader', 'jrxml', 'variable'))
|
40
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'loader', 'jrxml', 'static_text'))
|
41
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'loader', 'jrxml', 'text_field'))
|
42
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'loader', 'jrxml', 'image'))
|
43
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'loader', 'jrxml', 'client_combo_text_field'))
|
44
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'loader', 'jrxml', 'casper_text_field'))
|
45
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'loader', 'jrxml', 'casper_combo'))
|
46
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'loader', 'jrxml', 'casper_checkbox'))
|
47
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'loader', 'jrxml', 'casper_radio_button'))
|
48
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'loader', 'jrxml', 'casper_date'))
|
49
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'loader', 'jrxml', 'report_element'))
|
50
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'loader', 'jrxml', 'jasper'))
|
51
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'loader', 'jrxml', 'property'))
|
52
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'loader', 'jrxml', 'property_expression'))
|
53
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'loader', 'jrxml', 'extensions'))
|
54
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'loader', 'version'))
|
55
|
+
|
56
|
+
module Sp
|
57
|
+
module Excel
|
58
|
+
module Loader
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
#
|
3
|
+
# Copyright (c) 2011-2016 Cloudware S.A. All rights reserved.
|
4
|
+
#
|
5
|
+
# This file is part of sp-excel-loader.
|
6
|
+
#
|
7
|
+
# sp-excel-loader is free software: you can redistribute it and/or modify
|
8
|
+
# it under the terms of the GNU Affero General Public License as published by
|
9
|
+
# the Free Software Foundation, either version 3 of the License, or
|
10
|
+
# (at your option) any later version.
|
11
|
+
#
|
12
|
+
# sp-excel-loader is distributed in the hope that it will be useful,
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
# GNU General Public License for more details.
|
16
|
+
#
|
17
|
+
# You should have received a copy of the GNU Affero General Public License
|
18
|
+
# along with sp-excel-loader. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
#
|
20
|
+
|
21
|
+
module Sp
|
22
|
+
module Excel
|
23
|
+
module Loader
|
24
|
+
module Jrxml
|
25
|
+
|
26
|
+
class Band
|
27
|
+
|
28
|
+
attr_accessor :children
|
29
|
+
attr_accessor :height
|
30
|
+
attr_accessor :split_type
|
31
|
+
attr_accessor :print_when_expression
|
32
|
+
attr_accessor :properties
|
33
|
+
attr_accessor :auto_float
|
34
|
+
attr_accessor :auto_stretch
|
35
|
+
attr_accessor :stretch_type
|
36
|
+
|
37
|
+
def initialize
|
38
|
+
@children = Array.new
|
39
|
+
@height = 18;
|
40
|
+
@split_type = 'Prevent'
|
41
|
+
@print_when_expression = nil
|
42
|
+
@properties = nil
|
43
|
+
@auto_stretch = false
|
44
|
+
@auto_float = false
|
45
|
+
@stretch_type = nil
|
46
|
+
end
|
47
|
+
|
48
|
+
def attributes
|
49
|
+
rv = Hash.new
|
50
|
+
rv['height'] = @height
|
51
|
+
rv['splitType'] = @split_type
|
52
|
+
return rv
|
53
|
+
end
|
54
|
+
|
55
|
+
def to_xml (a_node)
|
56
|
+
Nokogiri::XML::Builder.with(a_node) do |xml|
|
57
|
+
xml.band(attributes) {
|
58
|
+
unless @properties.nil?
|
59
|
+
@properties.each do |property|
|
60
|
+
xml.property(property.attributes)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
unless @print_when_expression.nil?
|
64
|
+
xml.printWhenExpression {
|
65
|
+
xml.cdata @print_when_expression
|
66
|
+
}
|
67
|
+
end
|
68
|
+
}
|
69
|
+
end
|
70
|
+
@children.each do |child|
|
71
|
+
child.to_xml(a_node.children.last)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,229 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
#
|
3
|
+
# Copyright (c) 2011-2016 Cloudware S.A. All rights reserved.
|
4
|
+
#
|
5
|
+
# This file is part of sp-excel-loader.
|
6
|
+
#
|
7
|
+
# sp-excel-loader is free software: you can redistribute it and/or modify
|
8
|
+
# it under the terms of the GNU Affero General Public License as published by
|
9
|
+
# the Free Software Foundation, either version 3 of the License, or
|
10
|
+
# (at your option) any later version.
|
11
|
+
#
|
12
|
+
# sp-excel-loader is distributed in the hope that it will be useful,
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
# GNU General Public License for more details.
|
16
|
+
#
|
17
|
+
# You should have received a copy of the GNU Affero General Public License
|
18
|
+
# along with sp-excel-loader. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
#
|
20
|
+
|
21
|
+
module Sp
|
22
|
+
module Excel
|
23
|
+
module Loader
|
24
|
+
module Jrxml
|
25
|
+
|
26
|
+
class BandContainer
|
27
|
+
|
28
|
+
attr_accessor :bands
|
29
|
+
|
30
|
+
def initialize
|
31
|
+
@bands = Array.new
|
32
|
+
@band_type = nil
|
33
|
+
end
|
34
|
+
|
35
|
+
def attributes
|
36
|
+
rv = Hash.new
|
37
|
+
return rv
|
38
|
+
end
|
39
|
+
|
40
|
+
def bands_to_xml (a_node)
|
41
|
+
@bands.each do |band|
|
42
|
+
band.to_xml(a_node)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
class Background < BandContainer
|
49
|
+
|
50
|
+
def to_xml (a_node)
|
51
|
+
if @bands.size > 0
|
52
|
+
Nokogiri::XML::Builder.with(a_node) do |xml|
|
53
|
+
xml.background(attributes)
|
54
|
+
end
|
55
|
+
bands_to_xml(a_node.children.last)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
class PageHeader < BandContainer
|
62
|
+
|
63
|
+
def to_xml (a_node)
|
64
|
+
if @bands.size > 0
|
65
|
+
Nokogiri::XML::Builder.with(a_node) do |xml|
|
66
|
+
xml.pageHeader(attributes)
|
67
|
+
end
|
68
|
+
bands_to_xml(a_node.children.last)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
|
74
|
+
class ColumnHeader < BandContainer
|
75
|
+
|
76
|
+
def to_xml (a_node)
|
77
|
+
if @bands.size > 0
|
78
|
+
Nokogiri::XML::Builder.with(a_node) do |xml|
|
79
|
+
xml.columnHeader(attributes)
|
80
|
+
end
|
81
|
+
bands_to_xml(a_node.children.last)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
class GroupHeader < BandContainer
|
88
|
+
|
89
|
+
def to_xml (a_node)
|
90
|
+
if @bands.size > 0
|
91
|
+
Nokogiri::XML::Builder.with(a_node) do |xml|
|
92
|
+
xml.groupHeader(attributes)
|
93
|
+
end
|
94
|
+
bands_to_xml(a_node.children.last)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
end
|
99
|
+
|
100
|
+
class GroupFooter < BandContainer
|
101
|
+
|
102
|
+
def to_xml (a_node)
|
103
|
+
if @bands.size > 0
|
104
|
+
Nokogiri::XML::Builder.with(a_node) do |xml|
|
105
|
+
xml.groupFooter(attributes)
|
106
|
+
end
|
107
|
+
bands_to_xml(a_node.children.last)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
end
|
112
|
+
|
113
|
+
class Detail < BandContainer
|
114
|
+
|
115
|
+
def to_xml (a_node)
|
116
|
+
if @bands.size > 0
|
117
|
+
Nokogiri::XML::Builder.with(a_node) do |xml|
|
118
|
+
xml.detail(attributes)
|
119
|
+
end
|
120
|
+
bands_to_xml(a_node.children.last)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
end
|
125
|
+
|
126
|
+
class ColumnFooter < BandContainer
|
127
|
+
|
128
|
+
def to_xml (a_node)
|
129
|
+
if @bands.size > 0
|
130
|
+
Nokogiri::XML::Builder.with(a_node) do |xml|
|
131
|
+
xml.columnFooter(attributes)
|
132
|
+
end
|
133
|
+
bands_to_xml(a_node.children.last)
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
end
|
138
|
+
|
139
|
+
class PageFooter < BandContainer
|
140
|
+
|
141
|
+
def to_xml (a_node)
|
142
|
+
@bands.each do |band|
|
143
|
+
page_number_refs = []
|
144
|
+
band.children.each do |child|
|
145
|
+
if child.kind_of? TextField
|
146
|
+
if "$V{PAGE_NUMBER}" == child.text_field_expression
|
147
|
+
page_number_refs << child
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
if page_number_refs.length > 1
|
152
|
+
page_number_ref_count = 0
|
153
|
+
page_number_refs.each do |ref|
|
154
|
+
page_number_ref_count += 1
|
155
|
+
evaluation_time = ( 1 == page_number_ref_count ? "Now" : "Report" )
|
156
|
+
if ref.attributes.nil?
|
157
|
+
ref.attributes = { evaluationTime:"#{evaluation_time}" }
|
158
|
+
else
|
159
|
+
ref.attributes << { evaluationTime:"#{evaluation_time}" }
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
164
|
+
if @bands.size > 0
|
165
|
+
Nokogiri::XML::Builder.with(a_node) do |xml|
|
166
|
+
xml.pageFooter(attributes)
|
167
|
+
end
|
168
|
+
bands_to_xml(a_node.children.last)
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
end
|
173
|
+
|
174
|
+
class LastPageFooter < BandContainer
|
175
|
+
|
176
|
+
def to_xml (a_node)
|
177
|
+
if @bands.size > 0
|
178
|
+
Nokogiri::XML::Builder.with(a_node) do |xml|
|
179
|
+
xml.lastPageFooter(attributes)
|
180
|
+
end
|
181
|
+
bands_to_xml(a_node.children.last)
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
end
|
186
|
+
|
187
|
+
class Summary < BandContainer
|
188
|
+
|
189
|
+
def to_xml (a_node)
|
190
|
+
if @bands.size > 0
|
191
|
+
Nokogiri::XML::Builder.with(a_node) do |xml|
|
192
|
+
xml.summary(attributes)
|
193
|
+
end
|
194
|
+
bands_to_xml(a_node.children.last)
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
end
|
199
|
+
|
200
|
+
class Title < BandContainer
|
201
|
+
|
202
|
+
def to_xml (a_node)
|
203
|
+
if @bands.size > 0
|
204
|
+
Nokogiri::XML::Builder.with(a_node) do |xml|
|
205
|
+
xml.title(attributes)
|
206
|
+
end
|
207
|
+
bands_to_xml(a_node.children.last)
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
end
|
212
|
+
|
213
|
+
class NoData < BandContainer
|
214
|
+
|
215
|
+
def to_xml (a_node)
|
216
|
+
if @bands.size > 0
|
217
|
+
Nokogiri::XML::Builder.with(a_node) do |xml|
|
218
|
+
xml.noData(attributes)
|
219
|
+
end
|
220
|
+
bands_to_xml(a_node.children.last)
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
224
|
+
end
|
225
|
+
|
226
|
+
end
|
227
|
+
end
|
228
|
+
end
|
229
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
#
|
3
|
+
# Copyright (c) 2011-2016 Cloudware S.A. All rights reserved.
|
4
|
+
#
|
5
|
+
# This file is part of sp-excel-loader.
|
6
|
+
#
|
7
|
+
# sp-excel-loader is free software: you can redistribute it and/or modify
|
8
|
+
# it under the terms of the GNU Affero General Public License as published by
|
9
|
+
# the Free Software Foundation, either version 3 of the License, or
|
10
|
+
# (at your option) any later version.
|
11
|
+
#
|
12
|
+
# sp-excel-loader is distributed in the hope that it will be useful,
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
# GNU General Public License for more details.
|
16
|
+
#
|
17
|
+
# You should have received a copy of the GNU Affero General Public License
|
18
|
+
# along with sp-excel-loader. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
#
|
20
|
+
|
21
|
+
module Sp
|
22
|
+
module Excel
|
23
|
+
module Loader
|
24
|
+
module Jrxml
|
25
|
+
|
26
|
+
class Box
|
27
|
+
|
28
|
+
attr_accessor :top_pen
|
29
|
+
attr_accessor :bottom_pen
|
30
|
+
attr_accessor :left_pen
|
31
|
+
attr_accessor :right_pen
|
32
|
+
attr_accessor :padding
|
33
|
+
attr_accessor :top_padding
|
34
|
+
attr_accessor :leftPadding
|
35
|
+
attr_accessor :bottom_padding
|
36
|
+
attr_accessor :right_padding
|
37
|
+
|
38
|
+
def initialize
|
39
|
+
@top_pen = nil
|
40
|
+
@bottom_pen = nil
|
41
|
+
@left_pen = nil
|
42
|
+
@right_pen = nil
|
43
|
+
@padding = 1
|
44
|
+
@top_padding = nil
|
45
|
+
@leftPadding = nil
|
46
|
+
@bottom_padding = nil
|
47
|
+
@right_padding = nil
|
48
|
+
end
|
49
|
+
|
50
|
+
def attributes
|
51
|
+
rv = Hash.new
|
52
|
+
rv['padding'] = @padding unless @padding.nil?
|
53
|
+
rv['topPadding'] = @top_padding unless @top_padding.nil?
|
54
|
+
rv['leftPadding'] = @leftPadding unless @leftPadding.nil?
|
55
|
+
rv['bottomPadding'] = @bottom_padding unless @bottom_padding.nil?
|
56
|
+
rv['rightPadding'] = @right_padding unless @right_padding.nil?
|
57
|
+
return rv
|
58
|
+
end
|
59
|
+
|
60
|
+
def to_xml (a_node)
|
61
|
+
Nokogiri::XML::Builder.with(a_node) do |xml|
|
62
|
+
xml.box(attributes)
|
63
|
+
end
|
64
|
+
@top_pen.to_xml(a_node.children.last) unless @top_pen.nil?
|
65
|
+
@left_pen.to_xml(a_node.children.last) unless @left_pen.nil?
|
66
|
+
@bottom_pen.to_xml(a_node.children.last) unless @bottom_pen.nil?
|
67
|
+
@right_pen.to_xml(a_node.children.last) unless @right_pen.nil?
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|