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,200 @@
|
|
1
|
+
require 'rubyXL/objects/ooxml_object'
|
2
|
+
require 'rubyXL/objects/cell_style'
|
3
|
+
require 'rubyXL/objects/font'
|
4
|
+
require 'rubyXL/objects/fill'
|
5
|
+
require 'rubyXL/objects/border'
|
6
|
+
require 'rubyXL/objects/extensions'
|
7
|
+
|
8
|
+
module RubyXL
|
9
|
+
|
10
|
+
# http://www.schemacentral.com/sc/ooxml/e-ssml_numFmt-1.html
|
11
|
+
class NumberFormat < OOXMLObject
|
12
|
+
define_attribute(:numFmtId, :int, :required => true)
|
13
|
+
define_attribute(:formatCode, :string, :required => true)
|
14
|
+
define_element_name 'numFmt'
|
15
|
+
|
16
|
+
def is_date_format?
|
17
|
+
# v----- Toss all the escaped chars ------v v--- and see if any date-related remained
|
18
|
+
!!(format_code.gsub(/(\"[^\"]*\"|\[[^\]]*\]|[\\_*].)/i, '') =~ /[dmyhs]/i)
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
# http://www.schemacentral.com/sc/ooxml/e-ssml_numFmts-1.html
|
24
|
+
class NumberFormatContainer < OOXMLObject
|
25
|
+
define_child_node(RubyXL::NumberFormat, :collection => :with_count, :accessor => :number_formats)
|
26
|
+
define_element_name 'numFmts'
|
27
|
+
|
28
|
+
DEFAULT_NUMBER_FORMATS = self.new(:number_formats => [
|
29
|
+
RubyXL::NumberFormat.new(:num_fmt_id => 1, :format_code => '0'),
|
30
|
+
RubyXL::NumberFormat.new(:num_fmt_id => 2, :format_code => '0.00'),
|
31
|
+
RubyXL::NumberFormat.new(:num_fmt_id => 3, :format_code => '#, ##0'),
|
32
|
+
RubyXL::NumberFormat.new(:num_fmt_id => 4, :format_code => '#, ##0.00'),
|
33
|
+
RubyXL::NumberFormat.new(:num_fmt_id => 5, :format_code => '$#, ##0_);($#, ##0)'),
|
34
|
+
RubyXL::NumberFormat.new(:num_fmt_id => 6, :format_code => '$#, ##0_);[Red]($#, ##0)'),
|
35
|
+
RubyXL::NumberFormat.new(:num_fmt_id => 7, :format_code => '$#, ##0.00_);($#, ##0.00)'),
|
36
|
+
RubyXL::NumberFormat.new(:num_fmt_id => 8, :format_code => '$#, ##0.00_);[Red]($#, ##0.00)'),
|
37
|
+
RubyXL::NumberFormat.new(:num_fmt_id => 9, :format_code => '0%'),
|
38
|
+
RubyXL::NumberFormat.new(:num_fmt_id => 10, :format_code => '0.00%'),
|
39
|
+
RubyXL::NumberFormat.new(:num_fmt_id => 11, :format_code => '0.00E+00'),
|
40
|
+
RubyXL::NumberFormat.new(:num_fmt_id => 12, :format_code => '# ?/?'),
|
41
|
+
RubyXL::NumberFormat.new(:num_fmt_id => 13, :format_code => '# ??/??'),
|
42
|
+
RubyXL::NumberFormat.new(:num_fmt_id => 14, :format_code => 'm/d/yyyy'),
|
43
|
+
RubyXL::NumberFormat.new(:num_fmt_id => 15, :format_code => 'd-mmm-yy'),
|
44
|
+
RubyXL::NumberFormat.new(:num_fmt_id => 16, :format_code => 'd-mmm'),
|
45
|
+
RubyXL::NumberFormat.new(:num_fmt_id => 17, :format_code => 'mmm-yy'),
|
46
|
+
RubyXL::NumberFormat.new(:num_fmt_id => 18, :format_code => 'h:mm AM/PM'),
|
47
|
+
RubyXL::NumberFormat.new(:num_fmt_id => 19, :format_code => 'h:mm:ss AM/PM'),
|
48
|
+
RubyXL::NumberFormat.new(:num_fmt_id => 20, :format_code => 'h:mm'),
|
49
|
+
RubyXL::NumberFormat.new(:num_fmt_id => 21, :format_code => 'h:mm:ss'),
|
50
|
+
RubyXL::NumberFormat.new(:num_fmt_id => 22, :format_code => 'm/d/yyyy h:mm'),
|
51
|
+
RubyXL::NumberFormat.new(:num_fmt_id => 37, :format_code => '#, ##0_);(#, ##0)'),
|
52
|
+
RubyXL::NumberFormat.new(:num_fmt_id => 38, :format_code => '#, ##0_);[Red](#, ##0)'),
|
53
|
+
RubyXL::NumberFormat.new(:num_fmt_id => 39, :format_code => '#, ##0.00_);(#, ##0.00)'),
|
54
|
+
RubyXL::NumberFormat.new(:num_fmt_id => 40, :format_code => '#, ##0.00_);[Red](#, ##0.00)'),
|
55
|
+
RubyXL::NumberFormat.new(:num_fmt_id => 45, :format_code => 'mm:ss'),
|
56
|
+
RubyXL::NumberFormat.new(:num_fmt_id => 46, :format_code => '[h]:mm:ss'),
|
57
|
+
RubyXL::NumberFormat.new(:num_fmt_id => 47, :format_code => 'mm:ss.0'),
|
58
|
+
RubyXL::NumberFormat.new(:num_fmt_id => 48, :format_code => '##0.0E+0'),
|
59
|
+
RubyXL::NumberFormat.new(:num_fmt_id => 49, :format_code => '@')
|
60
|
+
])
|
61
|
+
|
62
|
+
def find_by_format_id(format_id)
|
63
|
+
number_formats.find { |fmt| fmt.num_fmt_id == format_id }
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
# http://www.schemacentral.com/sc/ooxml/e-ssml_cellStyleXfs-1.html
|
69
|
+
class CellStyleXFContainer < OOXMLObject
|
70
|
+
define_child_node(RubyXL::XF, :collection => :with_count, :accessor => :cell_style_xfs)
|
71
|
+
define_element_name 'cellStyleXfs'
|
72
|
+
|
73
|
+
def self.defaults
|
74
|
+
self.new(:cell_style_xfs => [ RubyXL::XF.new(:num_fmt_id => 0, :font_id => 0, :fill_id => 0, :border_id => 0) ])
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
# http://www.schemacentral.com/sc/ooxml/e-ssml_cellXfs-1.html
|
79
|
+
class CellXFContainer < OOXMLObject
|
80
|
+
define_child_node(RubyXL::XF, :collection => :with_count, :accessor => :xfs)
|
81
|
+
define_element_name 'cellXfs'
|
82
|
+
|
83
|
+
def self.defaults
|
84
|
+
self.new(:xfs => [
|
85
|
+
RubyXL::XF.new(
|
86
|
+
:num_fmt_id => 0, :font_id => 0, :fill_id => 0, :border_id => 0, :xfId => 0
|
87
|
+
)
|
88
|
+
])
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
# http://www.schemacentral.com/sc/ooxml/e-ssml_cellStyles-1.html
|
93
|
+
class CellStyleContainer < OOXMLObject
|
94
|
+
define_child_node(RubyXL::CellStyle, :collection => :with_count, :accessor => :cell_styles)
|
95
|
+
define_element_name 'cellStyles'
|
96
|
+
|
97
|
+
def self.defaults
|
98
|
+
self.new(:cell_styles => [ RubyXL::CellStyle.new(:builtin_id => 0, :name => 'Normal', :xf_id => 0) ])
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
# http://www.schemacentral.com/sc/ooxml/e-ssml_dxf-1.html
|
103
|
+
class DXF < OOXMLObject
|
104
|
+
define_child_node(RubyXL::Font)
|
105
|
+
define_child_node(RubyXL::NumberFormat)
|
106
|
+
define_child_node(RubyXL::Fill)
|
107
|
+
define_child_node(RubyXL::Alignment)
|
108
|
+
define_child_node(RubyXL::Border)
|
109
|
+
define_child_node(RubyXL::Protection)
|
110
|
+
define_child_node(RubyXL::ExtensionStorageArea)
|
111
|
+
define_element_name 'dxf'
|
112
|
+
end
|
113
|
+
|
114
|
+
# http://www.schemacentral.com/sc/ooxml/e-ssml_dxfs-1.html
|
115
|
+
class DXFs < OOXMLObject
|
116
|
+
define_child_node(RubyXL::DXF, :collection => :with_count)
|
117
|
+
define_element_name 'dxfs'
|
118
|
+
end
|
119
|
+
|
120
|
+
# http://www.schemacentral.com/sc/ooxml/e-ssml_tableStyle-1.html
|
121
|
+
class TableStyle < OOXMLObject
|
122
|
+
define_attribute(:name, :string, :required => true)
|
123
|
+
define_attribute(:pivot, :bool, :default => true)
|
124
|
+
define_attribute(:table, :bool, :default => true)
|
125
|
+
define_attribute(:count, :int)
|
126
|
+
define_element_name 'tableStyle'
|
127
|
+
end
|
128
|
+
|
129
|
+
# http://www.schemacentral.com/sc/ooxml/e-ssml_tableStyles-1.html
|
130
|
+
class TableStyles < OOXMLObject
|
131
|
+
define_attribute(:defaultTableStyle, :string)
|
132
|
+
define_attribute(:defaultPivotStyle, :string)
|
133
|
+
define_child_node(RubyXL::TableStyle, :collection => :with_count)
|
134
|
+
define_element_name 'tableStyles'
|
135
|
+
end
|
136
|
+
|
137
|
+
# http://www.schemacentral.com/sc/ooxml/e-ssml_colors-1.html
|
138
|
+
class ColorSet < OOXMLObject
|
139
|
+
define_child_node(RubyXL::Color, :collection => :true)
|
140
|
+
end
|
141
|
+
|
142
|
+
# http://www.schemacentral.com/sc/ooxml/e-ssml_colors-1.html
|
143
|
+
class Colors < OOXMLObject
|
144
|
+
define_child_node(RubyXL::ColorSet, :node_name => 'indexedColors')
|
145
|
+
define_child_node(RubyXL::ColorSet, :node_name => 'mruColors')
|
146
|
+
define_element_name 'colors'
|
147
|
+
end
|
148
|
+
|
149
|
+
# http://www.schemacentral.com/sc/ooxml/e-ssml_styleSheet.html
|
150
|
+
class Stylesheet < OOXMLObject
|
151
|
+
define_child_node(RubyXL::NumberFormatContainer, :accessor => :number_format_container)
|
152
|
+
define_child_node(RubyXL::FontContainer, :accessor => :font_container)
|
153
|
+
define_child_node(RubyXL::FillContainer, :accessor => :fill_container)
|
154
|
+
define_child_node(RubyXL::BorderContainer, :accessor => :border_container)
|
155
|
+
define_child_node(RubyXL::CellStyleXFContainer, :accessor => :cell_style_xf_container)
|
156
|
+
define_child_node(RubyXL::CellXFContainer, :accessor => :cell_xf_container)
|
157
|
+
define_child_node(RubyXL::CellStyleContainer, :accessor => :cell_style_container)
|
158
|
+
define_child_node(RubyXL::DXFs)
|
159
|
+
define_child_node(RubyXL::TableStyles)
|
160
|
+
define_child_node(RubyXL::Colors)
|
161
|
+
define_child_node(RubyXL::ExtensionStorageArea)
|
162
|
+
define_element_name 'styleSheet'
|
163
|
+
set_namespaces('xmlns' => 'http://schemas.openxmlformats.org/spreadsheetml/2006/main',
|
164
|
+
'xmlns:r' => 'http://schemas.openxmlformats.org/officeDocument/2006/relationships',
|
165
|
+
'xmlns:mc' => 'http://schemas.openxmlformats.org/markup-compatibility/2006',
|
166
|
+
'xmlns:x14ac' => 'http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac',
|
167
|
+
'xmlns:mv' => 'urn:schemas-microsoft-com:mac:vml')
|
168
|
+
|
169
|
+
def initialize(*args)
|
170
|
+
super
|
171
|
+
@format_hash = nil
|
172
|
+
end
|
173
|
+
|
174
|
+
def self.filepath
|
175
|
+
File.join('xl', 'styles.xml')
|
176
|
+
end
|
177
|
+
|
178
|
+
def self.default
|
179
|
+
self.new(:cell_xf_container => RubyXL::CellXFContainer.defaults,
|
180
|
+
:font_container => RubyXL::FontContainer.defaults,
|
181
|
+
:fill_container => RubyXL::FillContainer.defaults,
|
182
|
+
:border_container => RubyXL::BorderContainer.defaults,
|
183
|
+
:cell_style_container => RubyXL::CellStyleContainer.defaults,
|
184
|
+
:cell_style_xf_container => RubyXL::CellStyleXFContainer.defaults)
|
185
|
+
end
|
186
|
+
|
187
|
+
def get_number_format_by_id(format_id)
|
188
|
+
@format_hash ||= {}
|
189
|
+
|
190
|
+
if @format_hash[format_id].nil? then
|
191
|
+
@format_hash[format_id] = NumberFormatContainer::DEFAULT_NUMBER_FORMATS.find_by_format_id(format_id) ||
|
192
|
+
(number_format_container && number_format_container.find_by_format_id(format_id))
|
193
|
+
end
|
194
|
+
|
195
|
+
@format_hash[format_id]
|
196
|
+
end
|
197
|
+
|
198
|
+
end
|
199
|
+
|
200
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
require 'rubyXL/objects/ooxml_object'
|
2
|
+
require 'rubyXL/objects/container_nodes'
|
3
|
+
|
4
|
+
module RubyXL
|
5
|
+
|
6
|
+
# http://www.schemacentral.com/sc/ooxml/e-ssml_t-1.html
|
7
|
+
class Text < OOXMLObject
|
8
|
+
define_attribute(:_, :string, :accessor => :value)
|
9
|
+
define_attribute(:'xml:space', :string)
|
10
|
+
define_element_name 't'
|
11
|
+
|
12
|
+
def before_write_xml
|
13
|
+
self.xml_space = (value && (/^\s+/.match(value) || /\s+$/.match(value))) ? 'preserve' : nil
|
14
|
+
true
|
15
|
+
end
|
16
|
+
|
17
|
+
def to_s
|
18
|
+
value.to_s
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
# http://www.schemacentral.com/sc/ooxml/e-ssml_rPr-1.html
|
23
|
+
class RunProperties < OOXMLObject
|
24
|
+
define_child_node(RubyXL::StringValue, :node_name => :rFont)
|
25
|
+
define_child_node(RubyXL::IntegerValue, :node_name => :charset)
|
26
|
+
define_child_node(RubyXL::IntegerValue, :node_name => :family)
|
27
|
+
define_child_node(RubyXL::BooleanValue, :node_name => :b)
|
28
|
+
define_child_node(RubyXL::BooleanValue, :node_name => :i)
|
29
|
+
define_child_node(RubyXL::BooleanValue, :node_name => :strike)
|
30
|
+
define_child_node(RubyXL::BooleanValue, :node_name => :outline)
|
31
|
+
define_child_node(RubyXL::BooleanValue, :node_name => :shadow)
|
32
|
+
define_child_node(RubyXL::BooleanValue, :node_name => :condense)
|
33
|
+
define_child_node(RubyXL::BooleanValue, :node_name => :extend)
|
34
|
+
define_child_node(RubyXL::Color)
|
35
|
+
define_child_node(RubyXL::FloatValue, :node_name => :sz)
|
36
|
+
define_child_node(RubyXL::BooleanValue, :node_name => :u)
|
37
|
+
define_child_node(RubyXL::StringValue, :node_name => :vertAlign)
|
38
|
+
define_child_node(RubyXL::StringValue, :node_name => :scheme)
|
39
|
+
define_element_name 'rPr'
|
40
|
+
end
|
41
|
+
|
42
|
+
# http://www.schemacentral.com/sc/ooxml/e-ssml_r-2.html
|
43
|
+
class RichTextRun < OOXMLObject
|
44
|
+
define_child_node(RubyXL::RunProperties)
|
45
|
+
define_child_node(RubyXL::Text)
|
46
|
+
define_element_name 'r'
|
47
|
+
|
48
|
+
def to_s
|
49
|
+
t.to_s
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
# http://www.schemacentral.com/sc/ooxml/e-ssml_rPh-1.html
|
55
|
+
class PhoneticRun < OOXMLObject
|
56
|
+
define_attribute(:sb, :int, :required => true)
|
57
|
+
define_attribute(:eb, :int, :required => true)
|
58
|
+
define_child_node(RubyXL::Text)
|
59
|
+
define_element_name 'rPh'
|
60
|
+
end
|
61
|
+
|
62
|
+
# http://www.schemacentral.com/sc/ooxml/e-ssml_phoneticPr-1.html
|
63
|
+
class PhoneticProperties < OOXMLObject
|
64
|
+
define_attribute(:fontId, :int, :required => true)
|
65
|
+
define_attribute(:type, :string, :default => 'fullwidthKatakana',
|
66
|
+
:values => %w{ halfwidthKatakana fullwidthKatakana Hiragana noConversion })
|
67
|
+
define_attribute(:alignment, :string, :default => 'left',
|
68
|
+
:values => %w{ noControl left center distributed })
|
69
|
+
define_element_name 'phoneticPr'
|
70
|
+
end
|
71
|
+
|
72
|
+
# http://www.schemacentral.com/sc/ooxml/e-ssml_is-1.html
|
73
|
+
class RichText < OOXMLObject
|
74
|
+
define_child_node(RubyXL::Text)
|
75
|
+
define_child_node(RubyXL::RichTextRun, :collection => true)
|
76
|
+
define_child_node(RubyXL::PhoneticRun)
|
77
|
+
define_child_node(RubyXL::PhoneticProperties) # phoneticPr
|
78
|
+
define_element_name 'is'
|
79
|
+
|
80
|
+
def to_s
|
81
|
+
str = t.to_s
|
82
|
+
r && r.each { |rtr| str << rtr.to_s if rtr }
|
83
|
+
str
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'rubyXL/objects/ooxml_object'
|
2
|
+
require 'rubyXL/objects/extensions'
|
3
|
+
|
4
|
+
module RubyXL
|
5
|
+
|
6
|
+
# http://www.schemacentral.com/sc/ooxml/e-a_ext-1.html
|
7
|
+
class Extension < OOXMLObject
|
8
|
+
define_attribute(:uri, :string)
|
9
|
+
define_element_name 'a:ext'
|
10
|
+
attr_accessor :raw_xml
|
11
|
+
|
12
|
+
def self.parse(node)
|
13
|
+
obj = new
|
14
|
+
obj.raw_xml = node.to_xml
|
15
|
+
obj
|
16
|
+
end
|
17
|
+
|
18
|
+
def write_xml(xml, node_name_override = nil)
|
19
|
+
self.raw_xml
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
class AExtensionStorageArea < OOXMLObject
|
25
|
+
define_child_node(RubyXL::AExtension, :collection => true)
|
26
|
+
define_element_name 'a:extLst'
|
27
|
+
end
|
28
|
+
|
29
|
+
class ColorScheme < OOXMLObject
|
30
|
+
define_element_name 'a:clrScheme'
|
31
|
+
end
|
32
|
+
|
33
|
+
class FontScheme < OOXMLObject
|
34
|
+
define_element_name 'a:fontScheme'
|
35
|
+
end
|
36
|
+
|
37
|
+
class FormatScheme < OOXMLObject
|
38
|
+
define_element_name 'a:fmtScheme'
|
39
|
+
end
|
40
|
+
|
41
|
+
# http://www.schemacentral.com/sc/ooxml/e-a_themeElements-1.html
|
42
|
+
class ThemeElements < OOXMLObject
|
43
|
+
define_child_node(RubyXL::ColorScheme)
|
44
|
+
define_child_node(RubyXL::FontScheme)
|
45
|
+
define_child_node(RubyXL::FormatScheme)
|
46
|
+
define_child_node(RubyXL::AExtensionStorageArea)
|
47
|
+
define_element_name 'a:themeElements'
|
48
|
+
end
|
49
|
+
|
50
|
+
# http://www.schemacentral.com/sc/ooxml/e-a_theme.html
|
51
|
+
class Theme < OOXMLObject
|
52
|
+
define_attribute(:name, :string, :default => '')
|
53
|
+
define_child_node(RubyXL::ThemeElements)
|
54
|
+
define_child_node(RubyXL::ObjectDefaults)
|
55
|
+
#a:extraClrSchemeLst [0..1] Extra Color Scheme List
|
56
|
+
#a:custClrLst [0..1] Custom Color List
|
57
|
+
define_child_node(RubyXL::AExtensionStorageArea)
|
58
|
+
|
59
|
+
define_element_name 'a:theme'
|
60
|
+
|
61
|
+
set_namespaces('xmlns:a' => 'http://schemas.openxmlformats.org/drawingml/2006/main')
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
@@ -0,0 +1,233 @@
|
|
1
|
+
require 'rubyXL/objects/ooxml_object'
|
2
|
+
require 'rubyXL/objects/extensions'
|
3
|
+
|
4
|
+
module RubyXL
|
5
|
+
|
6
|
+
# Eventually, the entire code for Workbook will be moved here.
|
7
|
+
|
8
|
+
# http://www.schemacentral.com/sc/ooxml/e-ssml_fileVersion-1.html
|
9
|
+
class FileVersion < OOXMLObject
|
10
|
+
define_attribute(:appName, :string)
|
11
|
+
define_attribute(:lastEdited, :string)
|
12
|
+
define_attribute(:lowestEdited, :string)
|
13
|
+
define_attribute(:rupBuild, :string)
|
14
|
+
define_attribute(:codeName, :string)
|
15
|
+
define_element_name 'fileVersion'
|
16
|
+
end
|
17
|
+
|
18
|
+
# http://www.schemacentral.com/sc/ooxml/e-ssml_fileSharing-1.html
|
19
|
+
class FileSharing < OOXMLObject
|
20
|
+
define_attribute(:readOnlyRecommended, :bool, :default => false)
|
21
|
+
define_attribute(:userName, :string)
|
22
|
+
define_attribute(:reservationPassword, :string)
|
23
|
+
define_element_name 'fileSharing'
|
24
|
+
end
|
25
|
+
|
26
|
+
# http://www.schemacentral.com/sc/ooxml/e-ssml_workbookPr-1.html
|
27
|
+
class WorkbookProperties < OOXMLObject
|
28
|
+
define_attribute(:date1904, :bool, :default => false)
|
29
|
+
define_attribute(:showObjects, :string, :default => 'all', :values =>
|
30
|
+
%w{ all placeholders none } )
|
31
|
+
define_attribute(:showBorderUnselectedTables, :bool, :default => true)
|
32
|
+
define_attribute(:filterPrivacy, :bool, :default => false)
|
33
|
+
define_attribute(:promptedSolutions, :bool, :default => false)
|
34
|
+
define_attribute(:showInkAnnotation, :bool, :default => true)
|
35
|
+
define_attribute(:backupFile, :bool, :default => false)
|
36
|
+
define_attribute(:saveExternalLinkValues, :bool, :default => true)
|
37
|
+
define_attribute(:updateLinks, :string, :default => 'userSet', :values =>
|
38
|
+
%w{ userSet never always } )
|
39
|
+
define_attribute(:hidePivotFieldList, :bool, :default => false)
|
40
|
+
define_attribute(:showPivotChartFilter, :bool, :default => false)
|
41
|
+
define_attribute(:allowRefreshQuery, :bool, :default => false)
|
42
|
+
define_attribute(:publishItems, :bool, :default => false)
|
43
|
+
define_attribute(:checkCompatibility, :bool, :default => false)
|
44
|
+
define_attribute(:autoCompressPictures, :bool, :default => true)
|
45
|
+
define_attribute(:refreshAllConnections, :bool, :default => false)
|
46
|
+
define_attribute(:defaultThemeVersion, :int)
|
47
|
+
define_attribute(:codeName, :string)
|
48
|
+
define_element_name 'workbookPr'
|
49
|
+
end
|
50
|
+
|
51
|
+
# http://www.schemacentral.com/sc/ooxml/e-ssml_workbookProtection-1.html
|
52
|
+
class WorkbookProtection < OOXMLObject
|
53
|
+
define_attribute(:workbookPassword, :string)
|
54
|
+
define_attribute(:revisionsPassword, :string)
|
55
|
+
define_attribute(:lockStructure, :bool, :default => false)
|
56
|
+
define_attribute(:lockWindows, :bool, :default => false)
|
57
|
+
define_attribute(:lockRevision, :bool, :default => false)
|
58
|
+
define_element_name 'workbookProtection'
|
59
|
+
end
|
60
|
+
|
61
|
+
|
62
|
+
class WorkbookView < OOXMLObject
|
63
|
+
define_attribute(:visibility, :string, :default => 'visible', :values =>
|
64
|
+
%w{ visible hidden veryHidden } )
|
65
|
+
define_attribute(:minimized, :bool, :default => false)
|
66
|
+
define_attribute(:showHorizontalScroll, :bool, :default => true)
|
67
|
+
define_attribute(:showVerticalScroll, :bool, :default => true)
|
68
|
+
define_attribute(:showSheetTabs, :bool, :default => true)
|
69
|
+
define_attribute(:xWindow, :int)
|
70
|
+
define_attribute(:yWindow, :int)
|
71
|
+
define_attribute(:windowWidth, :int)
|
72
|
+
define_attribute(:windowHeight, :int)
|
73
|
+
define_attribute(:tabRatio, :int, :default => 600)
|
74
|
+
define_attribute(:firstSheet, :int, :default => 0)
|
75
|
+
define_attribute(:activeTab, :int, :default => 0)
|
76
|
+
define_attribute(:autoFilterDateGrouping, :bool, :default => true)
|
77
|
+
define_child_node(RubyXL::ExtensionStorageArea)
|
78
|
+
define_element_name 'workbookView'
|
79
|
+
end
|
80
|
+
|
81
|
+
# http://www.schemacentral.com/sc/ooxml/e-ssml_bookViews-1.html
|
82
|
+
class WorkbookViews < OOXMLObject
|
83
|
+
define_child_node(RubyXL::WorkbookView, :collection => true)
|
84
|
+
define_element_name 'bookViews'
|
85
|
+
end
|
86
|
+
|
87
|
+
# http://www.schemacentral.com/sc/ooxml/e-ssml_sheet-1.html
|
88
|
+
class Sheet < OOXMLObject
|
89
|
+
define_attribute(:name, :string, :required => true)
|
90
|
+
define_attribute(:sheetId, :int, :required => true)
|
91
|
+
define_attribute(:state, :string, :default => 'visible', :values =>
|
92
|
+
%w{ visible hidden veryHidden } )
|
93
|
+
define_attribute(:'r:id', :string, :required => true)
|
94
|
+
define_element_name 'sheet'
|
95
|
+
end
|
96
|
+
|
97
|
+
# http://www.schemacentral.com/sc/ooxml/e-ssml_sheets-1.html
|
98
|
+
class Sheets < OOXMLObject
|
99
|
+
define_child_node(RubyXL::Sheet, :collection => true, :accessor => :sheets)
|
100
|
+
define_element_name 'sheets'
|
101
|
+
end
|
102
|
+
|
103
|
+
# http://www.schemacentral.com/sc/ooxml/e-ssml_externalReference-1.html
|
104
|
+
class ExternalReference < OOXMLObject
|
105
|
+
define_attribute(:'r:id', :string, :required => true)
|
106
|
+
define_element_name 'externalReference'
|
107
|
+
end
|
108
|
+
|
109
|
+
# http://www.schemacentral.com/sc/ooxml/e-ssml_externalReferences-1.html
|
110
|
+
class ExternalReferences < OOXMLObject
|
111
|
+
define_child_node(RubyXL::ExternalReference, :collection => true, :accessor => :ext_refs)
|
112
|
+
define_element_name 'externalReferences'
|
113
|
+
end
|
114
|
+
|
115
|
+
# http://www.schemacentral.com/sc/ooxml/e-ssml_definedName-2.html
|
116
|
+
class DefinedName < OOXMLObject
|
117
|
+
define_attribute(:name, :string, :required => true)
|
118
|
+
define_attribute(:comment, :string)
|
119
|
+
define_attribute(:customMenu, :string)
|
120
|
+
define_attribute(:description, :string)
|
121
|
+
define_attribute(:help, :string)
|
122
|
+
define_attribute(:description, :string)
|
123
|
+
define_attribute(:localSheetId, :string)
|
124
|
+
|
125
|
+
define_attribute(:hidden, :bool, :default => false)
|
126
|
+
define_attribute(:function, :bool, :default => false)
|
127
|
+
define_attribute(:vbProcedure, :bool, :default => false)
|
128
|
+
define_attribute(:xlm, :bool, :default => false)
|
129
|
+
|
130
|
+
define_attribute(:functionGroupId, :int)
|
131
|
+
define_attribute(:shortcutKey, :string)
|
132
|
+
define_attribute(:publishToServer, :bool, :default => false)
|
133
|
+
define_attribute(:workbookParameter, :bool, :default => false)
|
134
|
+
|
135
|
+
define_attribute(:_, :string, :accessor => :reference)
|
136
|
+
define_element_name 'definedName'
|
137
|
+
end
|
138
|
+
|
139
|
+
# http://www.schemacentral.com/sc/ooxml/e-ssml_definedName-2.html
|
140
|
+
class DefinedNames < OOXMLObject
|
141
|
+
define_child_node(RubyXL::DefinedName, :collection => true, :accessor => :defined_names)
|
142
|
+
define_element_name 'definedNames'
|
143
|
+
end
|
144
|
+
|
145
|
+
class CalculationProperties < OOXMLObject
|
146
|
+
define_attribute(:calcId, :int)
|
147
|
+
define_attribute(:calcMode, :string, :default => 'auto', :values =>
|
148
|
+
%w{ manual auto autoNoTable } )
|
149
|
+
define_attribute(:fullCalcOnLoad, :bool, :default => false)
|
150
|
+
define_attribute(:refMode, :string, :default => 'A1', :values =>
|
151
|
+
%w{ A1 R1C1 } )
|
152
|
+
define_attribute(:iterate, :bool, :default => false)
|
153
|
+
define_attribute(:iterateCount, :int, :default => 100)
|
154
|
+
define_attribute(:iterateDelta, :float, :default => 0.001)
|
155
|
+
define_attribute(:fullPrecision, :bool, :default => true)
|
156
|
+
define_attribute(:calcCompleted, :bool, :default => true)
|
157
|
+
define_attribute(:calcOnSave, :bool, :default => true)
|
158
|
+
define_attribute(:concurrentCalc, :bool, :default => true)
|
159
|
+
define_attribute(:concurrentManualCount, :int)
|
160
|
+
define_attribute(:forceFullCalc, :bool)
|
161
|
+
define_element_name 'calcPr'
|
162
|
+
end
|
163
|
+
|
164
|
+
# http://www.schemacentral.com/sc/ooxml/e-ssml_workbook.html
|
165
|
+
class Workbook < OOXMLObject
|
166
|
+
define_child_node(RubyXL::FileVersion)
|
167
|
+
define_child_node(RubyXL::FileSharing)
|
168
|
+
define_child_node(RubyXL::WorkbookProperties, :accessor => :workbook_properties)
|
169
|
+
define_child_node(RubyXL::WorkbookProtection)
|
170
|
+
define_child_node(RubyXL::WorkbookViews)
|
171
|
+
define_child_node(RubyXL::Sheets, :accessor => :worksheet_container)
|
172
|
+
# ssml:functionGroups [0..1] Function Groups
|
173
|
+
define_child_node(RubyXL::ExternalReferences, :accessor => :ext_ref_container)
|
174
|
+
define_child_node(RubyXL::DefinedNames, :accessor => :defined_name_container)
|
175
|
+
define_child_node(RubyXL::CalculationProperties)
|
176
|
+
# ssml:oleSize [0..1] OLE Size
|
177
|
+
# ssml:customWorkbookViews [0..1] Custom Workbook Views
|
178
|
+
# ssml:pivotCaches [0..1] PivotCaches
|
179
|
+
# ssml:smartTagPr [0..1] Smart Tag Properties
|
180
|
+
# ssml:smartTagTypes [0..1] Smart Tag Types
|
181
|
+
# ssml:webPublishing [0..1] Web Publishing Properties
|
182
|
+
# ssml:fileRecoveryPr [0..*] File Recovery Properties
|
183
|
+
# ssml:webPublishObjects [0..1] Web Publish Objects
|
184
|
+
define_child_node(RubyXL::ExtensionStorageArea)
|
185
|
+
define_child_node(RubyXL::AlternateContent)
|
186
|
+
|
187
|
+
define_element_name 'workbook'
|
188
|
+
set_namespaces('xmlns' => 'http://schemas.openxmlformats.org/spreadsheetml/2006/main',
|
189
|
+
'xmlns:r' => 'http://schemas.openxmlformats.org/officeDocument/2006/relationships',
|
190
|
+
'xmlns:mc' => 'http://schemas.openxmlformats.org/markup-compatibility/2006',
|
191
|
+
'xmlns:x15' => 'http://schemas.microsoft.com/office/spreadsheetml/2010/11/main')
|
192
|
+
|
193
|
+
include LegacyWorkbook
|
194
|
+
|
195
|
+
def date1904
|
196
|
+
workbook_properties && workbook_properties.date1904
|
197
|
+
end
|
198
|
+
|
199
|
+
def date1904=(v)
|
200
|
+
self.workbook_properties ||= RubyXL::WorkbookProperties.new
|
201
|
+
workbook_properties.date1904 = v
|
202
|
+
end
|
203
|
+
|
204
|
+
def company
|
205
|
+
self.document_properties.company && self.document_properties.company.value
|
206
|
+
end
|
207
|
+
|
208
|
+
def company=(v)
|
209
|
+
self.document_properties.company ||= StringNode.new
|
210
|
+
self.document_properties.company.value = v
|
211
|
+
end
|
212
|
+
|
213
|
+
def application
|
214
|
+
self.document_properties.application && self.document_properties.application.value
|
215
|
+
end
|
216
|
+
|
217
|
+
def application=(v)
|
218
|
+
self.document_properties.application ||= StringNode.new
|
219
|
+
self.document_properties.application.value = v
|
220
|
+
end
|
221
|
+
|
222
|
+
def appversion
|
223
|
+
self.document_properties.app_version && self.document_properties.app_version.value
|
224
|
+
end
|
225
|
+
|
226
|
+
def appversion=(v)
|
227
|
+
self.document_properties.app_version ||= StringNode.new
|
228
|
+
self.document_properties.app_version.value = v
|
229
|
+
end
|
230
|
+
|
231
|
+
end
|
232
|
+
|
233
|
+
end
|