rubyXL 1.2.10 → 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +14 -10
- data/Gemfile.lock +80 -21
- data/LICENSE.txt +1 -1
- data/README.rdoc +88 -82
- data/Rakefile +7 -2
- data/VERSION +1 -1
- data/lib/rubyXL.rb +13 -7
- data/lib/rubyXL/cell.rb +108 -268
- data/lib/rubyXL/generic_storage.rb +40 -0
- data/lib/rubyXL/objects/border.rb +66 -0
- data/lib/rubyXL/objects/calculation_chain.rb +28 -0
- data/lib/rubyXL/objects/cell_style.rb +75 -0
- data/lib/rubyXL/objects/color.rb +25 -0
- data/lib/rubyXL/objects/column_range.rb +74 -0
- data/lib/rubyXL/objects/container_nodes.rb +122 -0
- data/lib/rubyXL/objects/data_validation.rb +43 -0
- data/lib/rubyXL/objects/document_properties.rb +76 -0
- data/lib/rubyXL/objects/extensions.rb +36 -0
- data/lib/rubyXL/objects/fill.rb +57 -0
- data/lib/rubyXL/objects/font.rb +111 -0
- data/lib/rubyXL/objects/formula.rb +24 -0
- data/lib/rubyXL/objects/ooxml_object.rb +295 -0
- data/lib/rubyXL/objects/reference.rb +110 -0
- data/lib/rubyXL/objects/relationships.rb +59 -0
- data/lib/rubyXL/objects/shared_strings.rb +57 -0
- data/lib/rubyXL/objects/sheet_data.rb +149 -0
- data/lib/rubyXL/objects/sheet_view.rb +71 -0
- data/lib/rubyXL/objects/stylesheet.rb +200 -0
- data/lib/rubyXL/objects/text.rb +87 -0
- data/lib/rubyXL/objects/theme.rb +64 -0
- data/lib/rubyXL/objects/workbook.rb +233 -0
- data/lib/rubyXL/objects/worksheet.rb +485 -0
- data/lib/rubyXL/parser.rb +78 -442
- data/lib/rubyXL/workbook.rb +216 -385
- data/lib/rubyXL/worksheet.rb +509 -1062
- data/lib/rubyXL/writer/content_types_writer.rb +104 -68
- data/lib/rubyXL/writer/core_writer.rb +26 -43
- data/lib/rubyXL/writer/generic_writer.rb +43 -0
- data/lib/rubyXL/writer/root_rels_writer.rb +11 -19
- data/lib/rubyXL/writer/styles_writer.rb +6 -398
- data/lib/rubyXL/writer/theme_writer.rb +321 -327
- data/lib/rubyXL/writer/workbook_writer.rb +63 -67
- data/lib/rubyXL/writer/worksheet_writer.rb +29 -218
- data/rdoc/created.rid +39 -0
- data/rdoc/fonts.css +167 -0
- data/rdoc/fonts/Lato-Light.ttf +0 -0
- data/rdoc/fonts/Lato-LightItalic.ttf +0 -0
- data/rdoc/fonts/Lato-Regular.ttf +0 -0
- data/rdoc/fonts/Lato-RegularItalic.ttf +0 -0
- data/rdoc/fonts/SourceCodePro-Bold.ttf +0 -0
- data/rdoc/fonts/SourceCodePro-Regular.ttf +0 -0
- data/rdoc/images/add.png +0 -0
- data/rdoc/images/arrow_up.png +0 -0
- data/rdoc/images/brick.png +0 -0
- data/rdoc/images/brick_link.png +0 -0
- data/rdoc/images/bug.png +0 -0
- data/rdoc/images/bullet_black.png +0 -0
- data/rdoc/images/bullet_toggle_minus.png +0 -0
- data/rdoc/images/bullet_toggle_plus.png +0 -0
- data/rdoc/images/date.png +0 -0
- data/rdoc/images/delete.png +0 -0
- data/rdoc/images/find.png +0 -0
- data/rdoc/images/loadingAnimation.gif +0 -0
- data/rdoc/images/macFFBgHack.png +0 -0
- data/rdoc/images/package.png +0 -0
- data/rdoc/images/page_green.png +0 -0
- data/rdoc/images/page_white_text.png +0 -0
- data/rdoc/images/page_white_width.png +0 -0
- data/rdoc/images/plugin.png +0 -0
- data/rdoc/images/ruby.png +0 -0
- data/rdoc/images/tag_blue.png +0 -0
- data/rdoc/images/tag_green.png +0 -0
- data/rdoc/images/transparent.png +0 -0
- data/rdoc/images/wrench.png +0 -0
- data/rdoc/images/wrench_orange.png +0 -0
- data/rdoc/images/zoom.png +0 -0
- data/rdoc/js/darkfish.js +140 -0
- data/rdoc/js/jquery.js +18 -0
- data/rdoc/js/navigation.js +142 -0
- data/rdoc/js/search.js +109 -0
- data/rdoc/js/search_index.js +1 -0
- data/rdoc/js/searcher.js +228 -0
- data/rdoc/rdoc.css +580 -0
- data/rubyXL.gemspec +90 -34
- data/spec/lib/cell_spec.rb +29 -59
- data/spec/lib/parser_spec.rb +35 -19
- data/spec/lib/reference_spec.rb +29 -0
- data/spec/lib/stylesheet_spec.rb +29 -0
- data/spec/lib/workbook_spec.rb +22 -17
- data/spec/lib/worksheet_spec.rb +47 -202
- metadata +185 -148
- data/lib/.DS_Store +0 -0
- data/lib/rubyXL/Hash.rb +0 -60
- data/lib/rubyXL/color.rb +0 -14
- data/lib/rubyXL/private_class.rb +0 -265
- data/lib/rubyXL/writer/app_writer.rb +0 -62
- data/lib/rubyXL/writer/calc_chain_writer.rb +0 -33
- data/lib/rubyXL/writer/shared_strings_writer.rb +0 -30
- data/lib/rubyXL/writer/workbook_rels_writer.rb +0 -59
- data/lib/rubyXL/zip.rb +0 -20
- data/spec/lib/hash_spec.rb +0 -28
@@ -0,0 +1,40 @@
|
|
1
|
+
module RubyXL
|
2
|
+
class GenericStorage < Hash
|
3
|
+
attr_reader :local_dir_path
|
4
|
+
|
5
|
+
def initialize(local_dir_path)
|
6
|
+
@local_dir_path = local_dir_path
|
7
|
+
@mode = 'r'
|
8
|
+
super
|
9
|
+
end
|
10
|
+
|
11
|
+
def binary
|
12
|
+
@mode = 'rb'
|
13
|
+
self
|
14
|
+
end
|
15
|
+
|
16
|
+
def load_dir(root_dir)
|
17
|
+
dirpath = File.join(root_dir, @local_dir_path)
|
18
|
+
if File.directory?(dirpath) then
|
19
|
+
(Dir.new(dirpath).entries - ['.', '..', '.DS_Store', '_rels']).each { |filename|
|
20
|
+
self[filename] = File.open(File.join(dirpath, filename), @mode).read
|
21
|
+
}
|
22
|
+
end
|
23
|
+
|
24
|
+
self
|
25
|
+
end
|
26
|
+
|
27
|
+
def load_file(root_dir, filename)
|
28
|
+
filepath = File.join(root_dir, @local_dir_path, filename)
|
29
|
+
self[filename] = File.open(filepath, @mode).read if File.readable?(filepath)
|
30
|
+
self
|
31
|
+
end
|
32
|
+
|
33
|
+
def add_to_zip(zipfile)
|
34
|
+
each_pair { |filename, data|
|
35
|
+
zipfile.get_output_stream(File.join(@local_dir_path, filename)) { |f| f << data }
|
36
|
+
}
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'rubyXL/objects/ooxml_object'
|
2
|
+
|
3
|
+
module RubyXL
|
4
|
+
|
5
|
+
class BorderEdge < OOXMLObject
|
6
|
+
define_attribute(:style, :string)
|
7
|
+
define_child_node(RubyXL::Color, :default => 'none', :values =>
|
8
|
+
%w{ none thin medium dashed dotted thick double hair
|
9
|
+
mediumDashed dashDot mediumDashDot dashDotDot slantDashDot } )
|
10
|
+
|
11
|
+
def ==(other)
|
12
|
+
style == other.style
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
# http://www.schemacentral.com/sc/ooxml/e-ssml_border-2.html
|
17
|
+
class Border < OOXMLObject
|
18
|
+
define_attribute(:diagonalUp, :bool)
|
19
|
+
define_attribute(:diagonalDown, :bool)
|
20
|
+
define_attribute(:outline, :bool, :default => true)
|
21
|
+
define_child_node(RubyXL::BorderEdge, :node_name => :left)
|
22
|
+
define_child_node(RubyXL::BorderEdge, :node_name => :right)
|
23
|
+
define_child_node(RubyXL::BorderEdge, :node_name => :top)
|
24
|
+
define_child_node(RubyXL::BorderEdge, :node_name => :bottom)
|
25
|
+
define_child_node(RubyXL::BorderEdge, :node_name => :diagonal)
|
26
|
+
define_child_node(RubyXL::BorderEdge, :node_name => :vertical)
|
27
|
+
define_child_node(RubyXL::BorderEdge, :node_name => :horizontal)
|
28
|
+
define_element_name 'border'
|
29
|
+
set_countable
|
30
|
+
|
31
|
+
def get_edge_style(direction)
|
32
|
+
edge = self.send(direction)
|
33
|
+
edge && edge.style
|
34
|
+
end
|
35
|
+
|
36
|
+
def set_edge_style(direction, style)
|
37
|
+
self.send("#{direction}=", RubyXL::BorderEdge.new(:style => style))
|
38
|
+
end
|
39
|
+
|
40
|
+
def ==(other)
|
41
|
+
(diagonal_up == other.diagonal_up) &&
|
42
|
+
(diagonal_down == other.diagonal_down) &&
|
43
|
+
(outline == other.outline) &&
|
44
|
+
(left == other.left) &&
|
45
|
+
(right == other.right) &&
|
46
|
+
(top == other.top) &&
|
47
|
+
(bottom == other.bottom) &&
|
48
|
+
(diagonal == other.diagonal) &&
|
49
|
+
(vertical == other.vertical) &&
|
50
|
+
(horizontal == other.horizontal)
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
# http://www.schemacentral.com/sc/ooxml/e-ssml_borders-1.html
|
56
|
+
class BorderContainer < OOXMLObject
|
57
|
+
define_child_node(RubyXL::Border, :collection => :with_count, :accessor => :borders)
|
58
|
+
define_element_name 'borders'
|
59
|
+
|
60
|
+
def self.defaults
|
61
|
+
self.new(:borders => [ RubyXL::Border.new ])
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'rubyXL/objects/ooxml_object'
|
2
|
+
require 'rubyXL/objects/extensions'
|
3
|
+
|
4
|
+
module RubyXL
|
5
|
+
# http://www.schemacentral.com/sc/ooxml/e-ssml_c-1.html
|
6
|
+
class CalculationChainCell < OOXMLObject
|
7
|
+
define_attribute(:r, :ref, :accessor => :ref)
|
8
|
+
define_attribute(:i, :int, :accessor => :sheet_id, :default => 0)
|
9
|
+
define_attribute(:s, :bool, :accessor => :child_chain, :default => false)
|
10
|
+
define_attribute(:l, :bool, :accessor => :new_dep_lvl, :default => false)
|
11
|
+
define_attribute(:t, :bool, :accessor => :new_thread, :default => false)
|
12
|
+
define_attribute(:a, :bool, :accessor => :array, :default => false)
|
13
|
+
define_element_name 'c'
|
14
|
+
end
|
15
|
+
|
16
|
+
# http://www.schemacentral.com/sc/ooxml/e-ssml_calcChain.html
|
17
|
+
class CalculationChain < OOXMLObject
|
18
|
+
define_child_node(RubyXL::CalculationChainCell, :collection => true, :accessor => :cells)
|
19
|
+
define_child_node(RubyXL::ExtensionStorageArea)
|
20
|
+
|
21
|
+
define_element_name 'calcChain'
|
22
|
+
set_namespaces('xmlns' => 'http://schemas.openxmlformats.org/spreadsheetml/2006/main')
|
23
|
+
|
24
|
+
def self.filepath
|
25
|
+
File.join('xl', 'calcChain.xml')
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'rubyXL/objects/ooxml_object'
|
2
|
+
|
3
|
+
module RubyXL
|
4
|
+
|
5
|
+
# http://www.schemacentral.com/sc/ooxml/e-ssml_cellStyle-1.html
|
6
|
+
class CellStyle < OOXMLObject
|
7
|
+
define_attribute(:name, :string)
|
8
|
+
define_attribute(:xfId, :int, :required => true)
|
9
|
+
define_attribute(:builtinId, :int)
|
10
|
+
define_attribute(:iLevel, :int)
|
11
|
+
define_attribute(:hidden, :bool)
|
12
|
+
define_attribute(:customBuiltin, :bool)
|
13
|
+
define_element_name 'cellStyle'
|
14
|
+
end
|
15
|
+
|
16
|
+
# http://www.schemacentral.com/sc/ooxml/e-ssml_alignment-1.html
|
17
|
+
class Alignment < OOXMLObject
|
18
|
+
define_attribute(:horizontal, :string,
|
19
|
+
:values => %w{general left center right fill justify centerContinuous distributed})
|
20
|
+
define_attribute(:vertical, :string,
|
21
|
+
:values => %w{top center bottom justify distributed})
|
22
|
+
define_attribute(:textRotation, :int)
|
23
|
+
define_attribute(:wrapText, :bool)
|
24
|
+
define_attribute(:indent, :int)
|
25
|
+
define_attribute(:relativeIndent, :int)
|
26
|
+
define_attribute(:justifyLastLine, :bool)
|
27
|
+
define_attribute(:shrinkToFit, :bool)
|
28
|
+
define_attribute(:readingOrder, :int)
|
29
|
+
define_element_name 'alignment'
|
30
|
+
end
|
31
|
+
|
32
|
+
# http://www.schemacentral.com/sc/ooxml/e-ssml_protection-1.html
|
33
|
+
class Protection < OOXMLObject
|
34
|
+
define_attribute(:locked, :bool)
|
35
|
+
define_attribute(:hidden, :bool)
|
36
|
+
define_element_name 'protection'
|
37
|
+
end
|
38
|
+
|
39
|
+
# http://www.schemacentral.com/sc/ooxml/e-ssml_xf-1.html
|
40
|
+
class XF < OOXMLObject
|
41
|
+
define_attribute(:numFmtId, :int)
|
42
|
+
define_attribute(:fontId, :int)
|
43
|
+
define_attribute(:fillId, :int)
|
44
|
+
define_attribute(:borderId, :int)
|
45
|
+
define_attribute(:xfId, :int)
|
46
|
+
define_attribute(:quotePrefix, :bool, :default => false )
|
47
|
+
define_attribute(:pivotButton, :bool, :default => false )
|
48
|
+
define_attribute(:applyNumberFormat, :bool)
|
49
|
+
define_attribute(:applyFont, :bool)
|
50
|
+
define_attribute(:applyFill, :bool)
|
51
|
+
define_attribute(:applyBorder, :bool)
|
52
|
+
define_attribute(:applyAlignment, :bool)
|
53
|
+
define_attribute(:applyProtection, :bool)
|
54
|
+
define_child_node(RubyXL::Alignment)
|
55
|
+
define_child_node(RubyXL::Protection)
|
56
|
+
define_element_name 'xf'
|
57
|
+
set_countable
|
58
|
+
|
59
|
+
def ==(other)
|
60
|
+
(self.num_fmt_id == other.num_fmt_id) &&
|
61
|
+
(self.font_id == other.font_id) &&
|
62
|
+
(self.fill_id == other.fill_id) &&
|
63
|
+
(self.border_id == other.border_id) &&
|
64
|
+
(self.xf_id == other.xf_id)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
# http://www.schemacentral.com/sc/ooxml/e-ssml_numFmt-1.html
|
69
|
+
class NumFmt < OOXMLObject
|
70
|
+
define_attribute(:numFmtId, :int, :required => true)
|
71
|
+
define_attribute(:formatCode, :string, :required => true)
|
72
|
+
define_element_name 'numFmt'
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'rubyXL/objects/ooxml_object'
|
2
|
+
|
3
|
+
module RubyXL
|
4
|
+
|
5
|
+
# http://www.schemacentral.com/sc/ooxml/e-ssml_color-4.html
|
6
|
+
class Color < OOXMLObject
|
7
|
+
define_attribute(:auto, :bool)
|
8
|
+
define_attribute(:indexed, :int)
|
9
|
+
define_attribute(:rgb, :string)
|
10
|
+
define_attribute(:theme, :int)
|
11
|
+
define_attribute(:tint, :float)
|
12
|
+
define_element_name 'color'
|
13
|
+
|
14
|
+
#validates hex color code, no '#' allowed
|
15
|
+
def self.validate_color(color)
|
16
|
+
if color =~ /^([a-f]|[A-F]|[0-9]){6}$/
|
17
|
+
return true
|
18
|
+
else
|
19
|
+
raise 'invalid color'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'rubyXL/objects/ooxml_object'
|
2
|
+
|
3
|
+
module RubyXL
|
4
|
+
|
5
|
+
# http://www.schemacentral.com/sc/ooxml/e-ssml_col-1.html
|
6
|
+
class ColumnRange < OOXMLObject
|
7
|
+
define_attribute(:min, :int, :required => true)
|
8
|
+
define_attribute(:max, :int, :required => true)
|
9
|
+
define_attribute(:width, :float)
|
10
|
+
define_attribute(:style, :int, :default => 0)
|
11
|
+
define_attribute(:hidden, :bool, :default => false)
|
12
|
+
define_attribute(:bestFit, :bool, :default => false)
|
13
|
+
define_attribute(:customWidth, :bool, :default => false)
|
14
|
+
define_attribute(:phonetic, :bool, :default => false)
|
15
|
+
define_attribute(:outlineLevel, :int, :default => 0)
|
16
|
+
define_attribute(:collapsed, :bool, :default => false)
|
17
|
+
define_element_name 'col'
|
18
|
+
|
19
|
+
def delete_column(col_index)
|
20
|
+
col = col_index + 1
|
21
|
+
self.min -=1 if min >= col
|
22
|
+
self.max -=1 if max >= col
|
23
|
+
end
|
24
|
+
|
25
|
+
def insert_column(col_index)
|
26
|
+
col = col_index + 1
|
27
|
+
self.min +=1 if min >= col
|
28
|
+
self.max +=1 if max >= col - 1
|
29
|
+
end
|
30
|
+
|
31
|
+
def include?(col_index)
|
32
|
+
((min-1)..(max-1)).include?(col_index)
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
class ColumnRanges < OOXMLObject
|
38
|
+
define_child_node(RubyXL::ColumnRange, :collection => true, :accessor => :column_ranges)
|
39
|
+
define_element_name 'cols'
|
40
|
+
|
41
|
+
# Locate an existing column range, make a new one if not found,
|
42
|
+
# or split existing column range into multiples.
|
43
|
+
def get_range(col_index)
|
44
|
+
col_num = col_index + 1
|
45
|
+
|
46
|
+
old_range = self.find(col_index)
|
47
|
+
|
48
|
+
if old_range.nil? then
|
49
|
+
new_range = RubyXL::ColumnRange.new(:min => col_num, :max => col_num)
|
50
|
+
self.column_ranges << new_range
|
51
|
+
return new_range
|
52
|
+
elsif old_range.min == col_num &&
|
53
|
+
old_range.max == col_num then # Single column range, OK to change in place
|
54
|
+
return old_range
|
55
|
+
else
|
56
|
+
raise "Range splitting not implemented yet"
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def find(col_index)
|
61
|
+
column_ranges && column_ranges.find { |range| range.include?(col_index) }
|
62
|
+
end
|
63
|
+
|
64
|
+
def insert_column(col_index)
|
65
|
+
column_ranges && column_ranges.each { |range| range.insert_column(col_index) }
|
66
|
+
end
|
67
|
+
|
68
|
+
def before_write_xml
|
69
|
+
!(column_ranges.nil? || column_ranges.empty?)
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
@@ -0,0 +1,122 @@
|
|
1
|
+
require 'rubyXL/objects/ooxml_object'
|
2
|
+
|
3
|
+
module RubyXL
|
4
|
+
|
5
|
+
class BooleanValue < OOXMLObject
|
6
|
+
define_attribute(:val, :bool, :required => true, :default => true)
|
7
|
+
end
|
8
|
+
|
9
|
+
class StringValue < OOXMLObject
|
10
|
+
define_attribute(:val, :string, :required => true)
|
11
|
+
end
|
12
|
+
|
13
|
+
class IntegerValue < OOXMLObject
|
14
|
+
define_attribute(:val, :int, :required => true)
|
15
|
+
end
|
16
|
+
|
17
|
+
class FloatValue < OOXMLObject
|
18
|
+
define_attribute(:val, :float, :required => true)
|
19
|
+
end
|
20
|
+
|
21
|
+
class BooleanNode < OOXMLObject
|
22
|
+
define_attribute(:_, :bool, :accessor => :value)
|
23
|
+
end
|
24
|
+
|
25
|
+
class StringNode < OOXMLObject
|
26
|
+
define_attribute(:_, :string, :accessor => :value)
|
27
|
+
end
|
28
|
+
|
29
|
+
class IntegerNode < OOXMLObject
|
30
|
+
define_attribute(:_, :int, :accessor => :value)
|
31
|
+
end
|
32
|
+
|
33
|
+
class FloatNode < OOXMLObject
|
34
|
+
define_attribute(:_, :float, :accessor => :value)
|
35
|
+
end
|
36
|
+
|
37
|
+
# http://www.schemacentral.com/sc/ooxml/e-docPropsVTypes_variant.html
|
38
|
+
class Variant < OOXMLObject
|
39
|
+
define_child_node(RubyXL::Variant, :node_name => 'vt:variant')
|
40
|
+
|
41
|
+
# vector Vector
|
42
|
+
# array Array
|
43
|
+
# blob Binary Blob
|
44
|
+
# oblob Binary Blob Object
|
45
|
+
# empty Empty
|
46
|
+
# null Null
|
47
|
+
# int Integer
|
48
|
+
# uint Unsigned Integer
|
49
|
+
# decimal Decimal
|
50
|
+
# stream Binary Stream
|
51
|
+
# ostream Binary Stream Object
|
52
|
+
# storage Binary Storage
|
53
|
+
# ostorage Binary Storage Object
|
54
|
+
# vstream Binary Versioned Stream
|
55
|
+
#
|
56
|
+
define_child_node(RubyXL::IntegerNode, :node_name => 'vt:i1')
|
57
|
+
define_child_node(RubyXL::IntegerNode, :node_name => 'vt:i2')
|
58
|
+
define_child_node(RubyXL::IntegerNode, :node_name => 'vt:i4')
|
59
|
+
define_child_node(RubyXL::IntegerNode, :node_name => 'vt:i8')
|
60
|
+
define_child_node(RubyXL::IntegerNode, :node_name => 'vt:ui1')
|
61
|
+
define_child_node(RubyXL::IntegerNode, :node_name => 'vt:ui2')
|
62
|
+
define_child_node(RubyXL::IntegerNode, :node_name => 'vt:ui4')
|
63
|
+
define_child_node(RubyXL::IntegerNode, :node_name => 'vt:ui8')
|
64
|
+
define_child_node(RubyXL::FloatNode, :node_name => 'vt:r4')
|
65
|
+
define_child_node(RubyXL::FloatNode, :node_name => 'vt:r8')
|
66
|
+
define_child_node(RubyXL::StringNode, :node_name => 'vt:lpstr')
|
67
|
+
define_child_node(RubyXL::StringNode, :node_name => 'vt:lpstrw')
|
68
|
+
define_child_node(RubyXL::StringNode, :node_name => 'vt:bstr')
|
69
|
+
define_child_node(RubyXL::StringNode, :node_name => 'vt:date')
|
70
|
+
define_child_node(RubyXL::StringNode, :node_name => 'vt:filetime')
|
71
|
+
define_child_node(RubyXL::BooleanNode, :node_name => 'vt:bool')
|
72
|
+
define_child_node(RubyXL::StringNode, :node_name => 'vt:cy')
|
73
|
+
define_child_node(RubyXL::StringNode, :node_name => 'vt:error')
|
74
|
+
define_child_node(RubyXL::StringNode, :node_name => 'vt:clsid')
|
75
|
+
define_child_node(RubyXL::StringNode, :node_name => 'vt:cf')
|
76
|
+
define_element_name 'vt:vector'
|
77
|
+
end
|
78
|
+
|
79
|
+
# http://www.schemacentral.com/sc/ooxml/e-docPropsVTypes_vector.html
|
80
|
+
class Vector < OOXMLObject
|
81
|
+
define_attribute(:baseType, :string, :required => true, :values =>
|
82
|
+
%w{ variant i1 i2 i4 i8 ui1 ui2 ui4 ui8 r4 r8
|
83
|
+
lpstr lpwstr bstr date filetime bool cy error clsid cf })
|
84
|
+
define_attribute(:size, :int, :required => true)
|
85
|
+
define_child_node(RubyXL::Variant, :collection => true, :node_name => 'vt:variant')
|
86
|
+
define_child_node(RubyXL::IntegerNode, :collection => true, :node_name => 'vt:i1')
|
87
|
+
define_child_node(RubyXL::IntegerNode, :collection => true, :node_name => 'vt:i2')
|
88
|
+
define_child_node(RubyXL::IntegerNode, :collection => true, :node_name => 'vt:i4')
|
89
|
+
define_child_node(RubyXL::IntegerNode, :collection => true, :node_name => 'vt:i8')
|
90
|
+
define_child_node(RubyXL::IntegerNode, :collection => true, :node_name => 'vt:ui1')
|
91
|
+
define_child_node(RubyXL::IntegerNode, :collection => true, :node_name => 'vt:ui2')
|
92
|
+
define_child_node(RubyXL::IntegerNode, :collection => true, :node_name => 'vt:ui4')
|
93
|
+
define_child_node(RubyXL::IntegerNode, :collection => true, :node_name => 'vt:ui8')
|
94
|
+
define_child_node(RubyXL::FloatNode, :collection => true, :node_name => 'vt:r4')
|
95
|
+
define_child_node(RubyXL::FloatNode, :collection => true, :node_name => 'vt:r8')
|
96
|
+
define_child_node(RubyXL::StringNode, :collection => true, :node_name => 'vt:lpstr')
|
97
|
+
define_child_node(RubyXL::StringNode, :collection => true, :node_name => 'vt:lpstrw')
|
98
|
+
define_child_node(RubyXL::StringNode, :collection => true, :node_name => 'vt:bstr')
|
99
|
+
define_child_node(RubyXL::StringNode, :collection => true, :node_name => 'vt:date')
|
100
|
+
define_child_node(RubyXL::StringNode, :collection => true, :node_name => 'vt:filetime')
|
101
|
+
define_child_node(RubyXL::BooleanNode, :collection => true, :node_name => 'vt:bool')
|
102
|
+
define_child_node(RubyXL::StringNode, :collection => true, :node_name => 'vt:cy')
|
103
|
+
define_child_node(RubyXL::StringNode, :collection => true, :node_name => 'vt:error')
|
104
|
+
define_child_node(RubyXL::StringNode, :collection => true, :node_name => 'vt:clsid')
|
105
|
+
define_child_node(RubyXL::StringNode, :collection => true, :node_name => 'vt:cf')
|
106
|
+
define_element_name 'vt:vector'
|
107
|
+
|
108
|
+
def before_write_xml
|
109
|
+
# Fill out the count attribute
|
110
|
+
known_child_nodes = obtain_class_variable(:@@ooxml_child_nodes)
|
111
|
+
self.size = 0
|
112
|
+
known_child_nodes.values.each { |v| self.size += self.send(v[:accessor]).size }
|
113
|
+
true
|
114
|
+
end
|
115
|
+
|
116
|
+
end
|
117
|
+
|
118
|
+
class VectorValue < OOXMLObject
|
119
|
+
define_child_node(RubyXL::Vector)
|
120
|
+
end
|
121
|
+
|
122
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'rubyXL/objects/ooxml_object'
|
2
|
+
require 'rubyXL/objects/formula'
|
3
|
+
|
4
|
+
module RubyXL
|
5
|
+
|
6
|
+
# http://www.schemacentral.com/sc/ooxml/e-ssml_dataValidation-1.html
|
7
|
+
class DataValidation < OOXMLObject
|
8
|
+
define_attribute(:type, :string, :default => 'none',
|
9
|
+
:values => %w{ none whole decimal list date time textLength custom })
|
10
|
+
define_attribute(:errorStyle, :string, :default => 'stop',
|
11
|
+
:values => %w{ stop warning information })
|
12
|
+
define_attribute(:imeMode, :string, :default => 'noControl',
|
13
|
+
:values => %w{ noControl off on disabled hiragana fullKatakana halfKatakana
|
14
|
+
fullAlpha halfAlpha fullHangul halfHangul })
|
15
|
+
define_attribute(:operator, :string, :default => 'between',
|
16
|
+
:values => %w{ between notBetween equal notEqual lessThan lessThanOrEqual
|
17
|
+
greaterThan greaterThanOrEqual })
|
18
|
+
define_attribute(:allowBlank, :bool, :default => false)
|
19
|
+
define_attribute(:showDropDown, :bool, :default => false)
|
20
|
+
define_attribute(:showInputMessage, :bool, :default => false)
|
21
|
+
define_attribute(:showErrorMessage, :bool, :default => false)
|
22
|
+
define_attribute(:errorTitle, :string)
|
23
|
+
define_attribute(:error, :string)
|
24
|
+
define_attribute(:promptTitle, :string)
|
25
|
+
define_attribute(:prompt, :string)
|
26
|
+
define_attribute(:sqref, :sqref, :required => true)
|
27
|
+
|
28
|
+
define_child_node(RubyXL::Formula, :node_name => :formula1)
|
29
|
+
define_child_node(RubyXL::Formula, :node_name => :formula2)
|
30
|
+
define_element_name 'dataValidation'
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
# http://www.schemacentral.com/sc/ooxml/e-ssml_dataValidations-1.html
|
35
|
+
class DataValidations < OOXMLObject
|
36
|
+
define_attribute(:disablePrompts, :bool, :default => false)
|
37
|
+
define_attribute(:xWindow, :int)
|
38
|
+
define_attribute(:yWindow, :int)
|
39
|
+
define_child_node(RubyXL::DataValidation, :collection => :with_count)
|
40
|
+
define_element_name 'dataValidations'
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|