sp-excel-loader 0.3.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +4 -0
  3. data/LICENSE +661 -0
  4. data/README.md +8 -0
  5. data/lib/sp-excel-loader.rb +6 -0
  6. data/lib/sp/excel/loader.rb +61 -0
  7. data/lib/sp/excel/loader/jrxml/band.rb +80 -0
  8. data/lib/sp/excel/loader/jrxml/band_container.rb +229 -0
  9. data/lib/sp/excel/loader/jrxml/box.rb +75 -0
  10. data/lib/sp/excel/loader/jrxml/casper_checkbox.rb +97 -0
  11. data/lib/sp/excel/loader/jrxml/casper_combo.rb +86 -0
  12. data/lib/sp/excel/loader/jrxml/casper_date.rb +54 -0
  13. data/lib/sp/excel/loader/jrxml/casper_radio_button.rb +48 -0
  14. data/lib/sp/excel/loader/jrxml/casper_text_field.rb +157 -0
  15. data/lib/sp/excel/loader/jrxml/client_combo_text_field.rb +72 -0
  16. data/lib/sp/excel/loader/jrxml/excel_to_jrxml.rb +1183 -0
  17. data/lib/sp/excel/loader/jrxml/extensions.rb +330 -0
  18. data/lib/sp/excel/loader/jrxml/field.rb +65 -0
  19. data/lib/sp/excel/loader/jrxml/group.rb +71 -0
  20. data/lib/sp/excel/loader/jrxml/image.rb +63 -0
  21. data/lib/sp/excel/loader/jrxml/jasper.rb +228 -0
  22. data/lib/sp/excel/loader/jrxml/parameter.rb +73 -0
  23. data/lib/sp/excel/loader/jrxml/pen.rb +97 -0
  24. data/lib/sp/excel/loader/jrxml/property.rb +52 -0
  25. data/lib/sp/excel/loader/jrxml/property_expression.rb +52 -0
  26. data/lib/sp/excel/loader/jrxml/report_element.rb +92 -0
  27. data/lib/sp/excel/loader/jrxml/static_text.rb +59 -0
  28. data/lib/sp/excel/loader/jrxml/style.rb +99 -0
  29. data/lib/sp/excel/loader/jrxml/text_field.rb +83 -0
  30. data/lib/sp/excel/loader/jrxml/variable.rb +77 -0
  31. data/lib/sp/excel/loader/json_to_xlsx.rb +159 -0
  32. data/lib/sp/excel/loader/model_exporter.rb +249 -0
  33. data/lib/sp/excel/loader/payrollexporter.rb +168 -0
  34. data/lib/sp/excel/loader/rubyxl_table_patch.rb +91 -0
  35. data/lib/sp/excel/loader/version.rb +26 -0
  36. data/lib/sp/excel/loader/workbookloader.rb +480 -0
  37. data/spec/calc_spec.rb +87 -0
  38. data/spec/model.xls +0 -0
  39. metadata +151 -0
@@ -0,0 +1,52 @@
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 Property
27
+
28
+ attr_accessor :name
29
+ attr_accessor :value
30
+
31
+ def initialize (a_name, a_value)
32
+ @name = a_name
33
+ @value = a_value
34
+ end
35
+
36
+ def attributes
37
+ { name: @name, value:@value }
38
+ end
39
+
40
+ def to_xml(a_node)
41
+ Nokogiri::XML::Builder.with(a_node) do |xml|
42
+ xml.property(attributes)
43
+ end
44
+ end
45
+
46
+ end
47
+
48
+ end
49
+
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,52 @@
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 PropertyExpression < Property
27
+
28
+ attr_accessor :name
29
+ attr_accessor :value
30
+
31
+ def initialize (a_name, a_value)
32
+ @name = a_name
33
+ @value = a_value
34
+ end
35
+
36
+ def attributes
37
+ { name: @name }
38
+ end
39
+
40
+ def to_xml(a_node)
41
+ Nokogiri::XML::Builder.with(a_node) do |xml|
42
+ xml.propertyExpression(attributes) { xml.cdata @value }
43
+ end
44
+ end
45
+
46
+ end
47
+
48
+ end
49
+
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,92 @@
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 ReportElement
27
+
28
+ attr_accessor :x
29
+ attr_accessor :y
30
+ attr_accessor :width
31
+ attr_accessor :height
32
+ attr_accessor :style
33
+ attr_accessor :properties
34
+ attr_accessor :position_type
35
+ attr_accessor :stretch_type
36
+ attr_accessor :print_when_expression
37
+
38
+ def initialize
39
+ @x = 0
40
+ @y = 0
41
+ @width = 0
42
+ @height = 0
43
+ @style = nil
44
+ @properties = nil
45
+ @position_type = 'FixRelativeToTop'
46
+ @stretch_type = 'NoStretch'
47
+ @print_when_expression = nil
48
+ end
49
+
50
+ def attributes
51
+ rv = Hash.new
52
+ rv['x'] = @x
53
+ rv['y'] = @y
54
+ rv['width'] = @width
55
+ rv['height'] = @height
56
+ rv['style'] = @style unless @style.nil?
57
+ rv['positionType'] = @position_type unless @position_type == 'FixRelativeToTop'
58
+ rv['stretchType'] = @stretch_type unless @stretch_type == 'NoStretch'
59
+ return rv
60
+ end
61
+
62
+ def to_xml (a_node)
63
+ Nokogiri::XML::Builder.with(a_node) do |xml|
64
+ xml.reportElement(attributes)
65
+ if not @properties.nil?
66
+ @properties.each do |property|
67
+ if property.instance_of? Property
68
+ property.to_xml(a_node.children.last)
69
+ end
70
+ end
71
+ @properties.each do |property|
72
+ if property.instance_of? PropertyExpression
73
+ property.to_xml(a_node.children.last)
74
+ end
75
+ end
76
+ end
77
+ unless @print_when_expression.nil?
78
+ Nokogiri::XML::Builder.with(a_node.children.last) do |xml|
79
+ xml.printWhenExpression {
80
+ xml.cdata(@print_when_expression)
81
+ }
82
+ end
83
+ end
84
+ end
85
+ end
86
+
87
+ end
88
+
89
+ end
90
+ end
91
+ end
92
+ end
@@ -0,0 +1,59 @@
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 StaticText
27
+
28
+ attr_accessor :report_element
29
+ attr_accessor :text
30
+ attr_accessor :style
31
+ attr_accessor :box
32
+ attr_accessor :attributes
33
+
34
+ def initialize
35
+ @report_element = ReportElement.new
36
+ @text = ''
37
+ @box = nil
38
+ @attributes = nil
39
+ end
40
+
41
+ def to_xml (a_node)
42
+ Nokogiri::XML::Builder.with(a_node) do |xml|
43
+ xml.staticText(attributes)
44
+ end
45
+ @report_element.to_xml(a_node.children.last)
46
+ @box.to_xml(a_node.children.last) unless @box.nil?
47
+ Nokogiri::XML::Builder.with(a_node.children.last) do |xml|
48
+ xml.text_ {
49
+ xml.cdata(@text)
50
+ }
51
+ end
52
+ end
53
+
54
+ end
55
+
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,99 @@
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 Style
27
+
28
+ attr_accessor :name
29
+ attr_accessor :style
30
+ attr_accessor :mode
31
+ attr_accessor :backcolor
32
+ attr_accessor :forecolor
33
+ attr_accessor :v_text_align
34
+ attr_accessor :h_text_align
35
+ attr_accessor :pattern
36
+ attr_accessor :font_name
37
+ attr_accessor :font_size
38
+ attr_accessor :is_blank_when_null
39
+ attr_accessor :is_bold
40
+ attr_accessor :is_italic
41
+ attr_accessor :pen
42
+ attr_accessor :box
43
+ attr_accessor :rotation
44
+
45
+ def initialize (a_name)
46
+ @name = a_name
47
+ @style = nil
48
+ @mode = nil
49
+ @backcolor = nil
50
+ @forecolor = nil
51
+ @v_text_align = nil
52
+ @h_text_align = nil
53
+ @pattern = nil
54
+ @font_size = nil
55
+ @font_name = 'DejaVu Sans Condensed'
56
+ @is_blank_when_null = true
57
+ @is_bold = nil
58
+ @is_italic = nil
59
+ @pen = nil
60
+ @box = nil
61
+ @rotation = nil
62
+ end
63
+
64
+ def to_xml (a_node)
65
+
66
+ attrs = Hash.new
67
+ attrs['name'] = @name
68
+ attrs['style'] = @style unless @style.nil?
69
+ attrs['mode'] = @mode unless @mode.nil?
70
+ attrs['backcolor'] = @backcolor unless @backcolor.nil?
71
+ attrs['mode'] = 'Opaque' unless @backcolor.nil?
72
+ attrs['forecolor'] = @forecolor unless @forecolor.nil?
73
+ attrs['vTextAlign'] = @v_text_align unless @v_text_align.nil?
74
+ attrs['hTextAlign'] = @h_text_align unless @h_text_align.nil?
75
+ attrs['pattern'] = @pattern unless @pattern.nil?
76
+ attrs['fontSize'] = @font_size unless @font_size.nil?
77
+ attrs['fontName'] = @font_name unless @font_size.nil? || @font_name == 'SansSerif'
78
+ attrs['isBlankWhenNull'] = @is_blank_when_null unless @is_blank_when_null.nil?
79
+ attrs['isBold'] = @is_bold unless @is_bold.nil?
80
+ attrs['isItalic'] = @is_italic unless @is_italic.nil?
81
+ attrs['rotation'] = @rotation unless @rotation.nil?
82
+
83
+ Nokogiri::XML::Builder.with(a_node) do |xml|
84
+ xml.style(attrs)
85
+ end
86
+ unless @pen.nil?
87
+ @pen.to_xml(a_node.children.last)
88
+ end
89
+ unless @box.nil?
90
+ @box.to_xml(a_node.children.last)
91
+ end
92
+ end
93
+
94
+ end # class Style
95
+
96
+ end
97
+ end
98
+ end
99
+ end
@@ -0,0 +1,83 @@
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 TextField < StaticText
27
+
28
+ attr_accessor :text_field_expression
29
+ attr_accessor :is_stretch_with_overflow
30
+ attr_accessor :is_blank_when_null
31
+ attr_accessor :evaluation_time
32
+ attr_accessor :pattern
33
+ attr_accessor :pattern_expression
34
+ attr_reader :report_element
35
+
36
+ def initialize (a_properties, a_pattern = nil, a_pattern_expression = nil)
37
+ super()
38
+ @text_field_expression = nil
39
+ @is_blank_when_null = nil
40
+ @is_stretch_with_overflow = false
41
+ @evaluation_time = nil
42
+ @pattern = a_pattern
43
+ @pattern_expression = a_pattern_expression
44
+ @report_element.properties = a_properties
45
+ end
46
+
47
+ def attributes
48
+ rv = Hash.new
49
+ rv['isStretchWithOverflow'] = true if @is_stretch_with_overflow
50
+ rv['pattern'] = @pattern unless @pattern.nil?
51
+ rv['isBlankWhenNull'] = @is_blank_when_null unless @is_blank_when_null.nil?
52
+ rv['evaluationTime'] = @evaluation_time unless @evaluation_time.nil?
53
+ return rv
54
+ end
55
+
56
+ def to_xml (a_node)
57
+ Nokogiri::XML::Builder.with(a_node) do |xml|
58
+ xml.textField(attributes)
59
+ end
60
+ @report_element.to_xml(a_node.children.last)
61
+ @box.to_xml(a_node.children.last) unless @box.nil?
62
+ if nil != @text_field_expression && @text_field_expression.length > 0
63
+ Nokogiri::XML::Builder.with(a_node.children.last) do |xml|
64
+ xml.textFieldExpression {
65
+ xml.cdata(@text_field_expression)
66
+ }
67
+ end
68
+ end
69
+ if nil != @pattern_expression && @pattern_expression.length > 0
70
+ Nokogiri::XML::Builder.with(a_node.children.last) do |xml|
71
+ xml.patternExpression {
72
+ xml.cdata(@pattern_expression)
73
+ }
74
+ end
75
+ end
76
+ end
77
+
78
+ end
79
+
80
+ end
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,77 @@
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 Variable
27
+
28
+ attr_accessor :name
29
+ attr_accessor :java_class
30
+ attr_accessor :calculation
31
+ attr_accessor :reset_type
32
+ attr_accessor :variable_expression
33
+ attr_accessor :initial_value_expression
34
+
35
+ def initialize (a_name, a_java_class = nil)
36
+ @name = a_name
37
+ @java_class = a_java_class
38
+ @java_class ||= 'java.lang.String'
39
+ @calculation = 'System'
40
+ @reset_type = nil
41
+ @variable_expression = nil
42
+ @initial_value_expression = nil
43
+ end
44
+
45
+ def attributes
46
+ rv = Hash.new
47
+ rv['name'] = @name
48
+ rv['class'] = @java_class
49
+ rv['calculation'] = @calculation
50
+ rv['resetType'] = @reset_type unless @reset_type.nil? or @reset_type == 'None'
51
+ rv['resetGroup'] = 'Group1' if @reset_type == 'Group'
52
+ return rv
53
+ end
54
+
55
+ def to_xml (a_node)
56
+ Nokogiri::XML::Builder.with(a_node) do |xml|
57
+ xml.variable(attributes) {
58
+ unless @variable_expression.nil?
59
+ xml.variableExpression {
60
+ xml.cdata @variable_expression
61
+ }
62
+ end
63
+ unless @initial_value_expression.nil?
64
+ xml.initialValueExpression {
65
+ xml.cdata @initial_value_expression
66
+ }
67
+ end
68
+ }
69
+ end
70
+ end
71
+
72
+ end
73
+
74
+ end
75
+ end
76
+ end
77
+ end