axlsx 2.0.1 → 2.1.0.pre
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.
- checksums.yaml +4 -4
- data/README.md +6 -3
- data/Rakefile +9 -10
- data/examples/IMAGE1UP.JPEG +0 -0
- data/examples/auto_filter.rb +10 -1
- data/examples/conditional_formatting/example_conditional_formatting.rb +3 -3
- data/examples/example.rb +72 -4
- data/examples/merge_cells.rb +17 -0
- data/examples/no_grid_with_borders.rb +18 -0
- data/examples/pivot_test.rb +63 -0
- data/examples/split.rb +16 -0
- data/lib/axlsx.rb +30 -16
- data/lib/axlsx/content_type/abstract_content_type.rb +1 -1
- data/lib/axlsx/content_type/content_type.rb +1 -1
- data/lib/axlsx/doc_props/app.rb +1 -1
- data/lib/axlsx/doc_props/core.rb +5 -5
- data/lib/axlsx/drawing/axes.rb +1 -1
- data/lib/axlsx/drawing/axis.rb +12 -9
- data/lib/axlsx/drawing/bar_3D_chart.rb +13 -13
- data/lib/axlsx/drawing/bar_series.rb +9 -9
- data/lib/axlsx/drawing/bubble_chart.rb +59 -0
- data/lib/axlsx/drawing/bubble_series.rb +63 -0
- data/lib/axlsx/drawing/cat_axis.rb +5 -5
- data/lib/axlsx/drawing/chart.rb +44 -7
- data/lib/axlsx/drawing/drawing.rb +3 -1
- data/lib/axlsx/drawing/graphic_frame.rb +3 -3
- data/lib/axlsx/drawing/hyperlink.rb +1 -3
- data/lib/axlsx/drawing/line_3D_chart.rb +2 -2
- data/lib/axlsx/drawing/line_chart.rb +10 -10
- data/lib/axlsx/drawing/line_series.rb +14 -2
- data/lib/axlsx/drawing/marker.rb +1 -1
- data/lib/axlsx/drawing/num_data.rb +4 -4
- data/lib/axlsx/drawing/num_data_source.rb +6 -6
- data/lib/axlsx/drawing/num_val.rb +1 -1
- data/lib/axlsx/drawing/one_cell_anchor.rb +1 -1
- data/lib/axlsx/drawing/pic.rb +2 -3
- data/lib/axlsx/drawing/picture_locking.rb +1 -3
- data/lib/axlsx/drawing/pie_3D_chart.rb +5 -6
- data/lib/axlsx/drawing/pie_series.rb +6 -6
- data/lib/axlsx/drawing/scaling.rb +4 -4
- data/lib/axlsx/drawing/scatter_chart.rb +10 -10
- data/lib/axlsx/drawing/scatter_series.rb +26 -7
- data/lib/axlsx/drawing/ser_axis.rb +2 -2
- data/lib/axlsx/drawing/series.rb +3 -3
- data/lib/axlsx/drawing/series_title.rb +2 -2
- data/lib/axlsx/drawing/str_data.rb +3 -3
- data/lib/axlsx/drawing/str_val.rb +1 -1
- data/lib/axlsx/drawing/title.rb +3 -3
- data/lib/axlsx/drawing/val_axis.rb +1 -1
- data/lib/axlsx/drawing/vml_drawing.rb +1 -1
- data/lib/axlsx/package.rb +39 -28
- data/lib/axlsx/rels/relationship.rb +1 -1
- data/lib/axlsx/rels/relationships.rb +2 -2
- data/lib/axlsx/stylesheet/border_pr.rb +2 -2
- data/lib/axlsx/stylesheet/cell_alignment.rb +1 -3
- data/lib/axlsx/stylesheet/cell_protection.rb +1 -3
- data/lib/axlsx/stylesheet/cell_style.rb +1 -3
- data/lib/axlsx/stylesheet/color.rb +1 -3
- data/lib/axlsx/stylesheet/font.rb +1 -1
- data/lib/axlsx/stylesheet/gradient_stop.rb +1 -1
- data/lib/axlsx/stylesheet/num_fmt.rb +1 -3
- data/lib/axlsx/stylesheet/pattern_fill.rb +1 -1
- data/lib/axlsx/stylesheet/styles.rb +6 -6
- data/lib/axlsx/stylesheet/table_style_element.rb +1 -3
- data/lib/axlsx/util/accessors.rb +6 -6
- data/lib/axlsx/util/constants.rb +106 -101
- data/lib/axlsx/util/options_parser.rb +2 -1
- data/lib/axlsx/util/parser.rb +4 -4
- data/lib/axlsx/util/serialized_attributes.rb +16 -6
- data/lib/axlsx/util/simple_typed_list.rb +28 -52
- data/lib/axlsx/util/storage.rb +4 -4
- data/lib/axlsx/util/string.rb +7 -0
- data/lib/axlsx/util/validators.rb +20 -13
- data/lib/axlsx/version.rb +1 -1
- data/lib/axlsx/workbook/defined_name.rb +11 -12
- data/lib/axlsx/workbook/defined_names.rb +2 -2
- data/lib/axlsx/workbook/shared_strings_table.rb +5 -5
- data/lib/axlsx/workbook/workbook.rb +19 -12
- data/lib/axlsx/workbook/workbook_view.rb +78 -0
- data/lib/axlsx/workbook/workbook_views.rb +22 -0
- data/lib/axlsx/workbook/worksheet/auto_filter/auto_filter.rb +2 -2
- data/lib/axlsx/workbook/worksheet/auto_filter/filters.rb +1 -3
- data/lib/axlsx/workbook/worksheet/break.rb +1 -3
- data/lib/axlsx/workbook/worksheet/cell.rb +128 -73
- data/lib/axlsx/workbook/worksheet/cell_serializer.rb +50 -40
- data/lib/axlsx/workbook/worksheet/cfvo.rb +1 -3
- data/lib/axlsx/workbook/worksheet/cfvos.rb +1 -1
- data/lib/axlsx/workbook/worksheet/col.rb +7 -10
- data/lib/axlsx/workbook/worksheet/col_breaks.rb +2 -2
- data/lib/axlsx/workbook/worksheet/comment.rb +5 -6
- data/lib/axlsx/workbook/worksheet/comments.rb +9 -12
- data/lib/axlsx/workbook/worksheet/conditional_formatting.rb +1 -1
- data/lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb +1 -1
- data/lib/axlsx/workbook/worksheet/data_bar.rb +4 -6
- data/lib/axlsx/workbook/worksheet/data_validation.rb +6 -4
- data/lib/axlsx/workbook/worksheet/dimension.rb +2 -2
- data/lib/axlsx/workbook/worksheet/header_footer.rb +6 -8
- data/lib/axlsx/workbook/worksheet/icon_set.rb +3 -5
- data/lib/axlsx/workbook/worksheet/merged_cells.rb +2 -2
- data/lib/axlsx/workbook/worksheet/page_margins.rb +1 -3
- data/lib/axlsx/workbook/worksheet/page_set_up_pr.rb +1 -1
- data/lib/axlsx/workbook/worksheet/page_setup.rb +21 -23
- data/lib/axlsx/workbook/worksheet/pane.rb +1 -3
- data/lib/axlsx/workbook/worksheet/pivot_table.rb +17 -24
- data/lib/axlsx/workbook/worksheet/pivot_table_cache_definition.rb +4 -4
- data/lib/axlsx/workbook/worksheet/print_options.rb +1 -3
- data/lib/axlsx/workbook/worksheet/protected_range.rb +1 -3
- data/lib/axlsx/workbook/worksheet/protected_ranges.rb +1 -1
- data/lib/axlsx/workbook/worksheet/rich_text.rb +35 -0
- data/lib/axlsx/workbook/worksheet/rich_text_run.rb +254 -0
- data/lib/axlsx/workbook/worksheet/row.rb +33 -51
- data/lib/axlsx/workbook/worksheet/row_breaks.rb +2 -2
- data/lib/axlsx/workbook/worksheet/selection.rb +1 -3
- data/lib/axlsx/workbook/worksheet/sheet_data.rb +3 -1
- data/lib/axlsx/workbook/worksheet/sheet_protection.rb +1 -3
- data/lib/axlsx/workbook/worksheet/table.rb +6 -6
- data/lib/axlsx/workbook/worksheet/table_style_info.rb +1 -3
- data/lib/axlsx/workbook/worksheet/tables.rb +1 -1
- data/lib/axlsx/workbook/worksheet/worksheet.rb +59 -30
- data/lib/axlsx/workbook/worksheet/worksheet_hyperlinks.rb +3 -3
- data/test/drawing/tc_axis.rb +27 -0
- data/test/drawing/tc_bubble_chart.rb +44 -0
- data/test/drawing/tc_bubble_series.rb +21 -0
- data/test/drawing/tc_data_source.rb +6 -0
- data/test/drawing/tc_line_chart.rb +5 -5
- data/test/drawing/tc_line_series.rb +10 -2
- data/test/drawing/tc_pic.rb +4 -0
- data/test/drawing/tc_scatter_series.rb +25 -1
- data/test/tc_helper.rb +1 -1
- data/test/tc_package.rb +7 -1
- data/test/util/tc_simple_typed_list.rb +1 -2
- data/test/workbook/tc_defined_name.rb +12 -4
- data/test/workbook/tc_workbook.rb +16 -2
- data/test/workbook/tc_workbook_view.rb +50 -0
- data/test/workbook/worksheet/auto_filter/tc_filters.rb +1 -1
- data/test/workbook/worksheet/tc_break.rb +1 -1
- data/test/workbook/worksheet/tc_cell.rb +30 -4
- data/test/workbook/worksheet/tc_col.rb +2 -2
- data/test/workbook/worksheet/tc_conditional_formatting.rb +2 -2
- data/test/workbook/worksheet/tc_data_bar.rb +1 -1
- data/test/workbook/worksheet/tc_data_validation.rb +11 -11
- data/test/workbook/worksheet/tc_header_footer.rb +2 -2
- data/test/workbook/worksheet/tc_icon_set.rb +1 -1
- data/test/workbook/worksheet/tc_page_setup.rb +3 -3
- data/test/workbook/worksheet/tc_print_options.rb +1 -1
- data/test/workbook/worksheet/tc_rich_text.rb +44 -0
- data/test/workbook/worksheet/tc_rich_text_run.rb +172 -0
- data/test/workbook/worksheet/tc_row.rb +2 -2
- data/test/workbook/worksheet/tc_sheet_calc_pr.rb +1 -1
- data/test/workbook/worksheet/tc_sheet_format_pr.rb +4 -4
- data/test/workbook/worksheet/tc_sheet_protection.rb +5 -5
- data/test/workbook/worksheet/tc_sheet_view.rb +4 -4
- data/test/workbook/worksheet/tc_worksheet.rb +49 -10
- metadata +81 -55
- data/test/axlsx.qcachegrind +0 -2226
|
@@ -26,7 +26,7 @@ module Axlsx
|
|
|
26
26
|
# serialize the object
|
|
27
27
|
def to_xml_string(idx, str = "")
|
|
28
28
|
Axlsx::validate_unsigned_int(idx)
|
|
29
|
-
str << '<c:pt idx="' << idx.to_s << '"><c:v>' << v.to_s << '</c:v></c:pt>'
|
|
29
|
+
str << ('<c:pt idx="' << idx.to_s << '"><c:v>' << v.to_s << '</c:v></c:pt>')
|
|
30
30
|
end
|
|
31
31
|
end
|
|
32
32
|
end
|
data/lib/axlsx/drawing/title.rb
CHANGED
|
@@ -48,11 +48,11 @@ module Axlsx
|
|
|
48
48
|
str << '<c:tx>'
|
|
49
49
|
if @cell.is_a?(Cell)
|
|
50
50
|
str << '<c:strRef>'
|
|
51
|
-
str << '<c:f>' << Axlsx::cell_range([@cell]) << '</c:f>'
|
|
51
|
+
str << ('<c:f>' << Axlsx::cell_range([@cell]) << '</c:f>')
|
|
52
52
|
str << '<c:strCache>'
|
|
53
53
|
str << '<c:ptCount val="1"/>'
|
|
54
54
|
str << '<c:pt idx="0">'
|
|
55
|
-
str << '<c:v>' << @text << '</c:v>'
|
|
55
|
+
str << ('<c:v>' << @text << '</c:v>')
|
|
56
56
|
str << '</c:pt>'
|
|
57
57
|
str << '</c:strCache>'
|
|
58
58
|
str << '</c:strRef>'
|
|
@@ -62,7 +62,7 @@ module Axlsx
|
|
|
62
62
|
str << '<a:lstStyle/>'
|
|
63
63
|
str << '<a:p>'
|
|
64
64
|
str << '<a:r>'
|
|
65
|
-
str << '<a:t>' << @text.to_s << '</a:t>'
|
|
65
|
+
str << ('<a:t>' << @text.to_s << '</a:t>')
|
|
66
66
|
str << '</a:r>'
|
|
67
67
|
str << '</a:p>'
|
|
68
68
|
str << '</c:rich>'
|
|
@@ -20,7 +20,7 @@ module Axlsx
|
|
|
20
20
|
# @param [String] str
|
|
21
21
|
# @return [String]
|
|
22
22
|
def to_xml_string(str = '')
|
|
23
|
-
str
|
|
23
|
+
str << <<BAD_PROGRAMMER
|
|
24
24
|
<xml xmlns:v="urn:schemas-microsoft-com:vml"
|
|
25
25
|
xmlns:o="urn:schemas-microsoft-com:office:office"
|
|
26
26
|
xmlns:x="urn:schemas-microsoft-com:office:excel">
|
data/lib/axlsx/package.rb
CHANGED
|
@@ -22,7 +22,7 @@ module Axlsx
|
|
|
22
22
|
# @example Package.new :author => 'you!', :workbook => Workbook.new
|
|
23
23
|
def initialize(options={})
|
|
24
24
|
@workbook = nil
|
|
25
|
-
@core, @app
|
|
25
|
+
@core, @app = Core.new, App.new
|
|
26
26
|
@core.creator = options[:author] || @core.creator
|
|
27
27
|
@core.created = options[:created_at]
|
|
28
28
|
parse_options options
|
|
@@ -76,7 +76,7 @@ module Axlsx
|
|
|
76
76
|
#end
|
|
77
77
|
|
|
78
78
|
# @see workbook
|
|
79
|
-
def workbook=(workbook) DataTypeValidator.validate
|
|
79
|
+
def workbook=(workbook) DataTypeValidator.validate :Package_workbook, Workbook, workbook; @workbook = workbook; end
|
|
80
80
|
|
|
81
81
|
# Serialize your workbook to disk as an xlsx document.
|
|
82
82
|
#
|
|
@@ -114,7 +114,7 @@ module Axlsx
|
|
|
114
114
|
def to_stream(confirm_valid=false)
|
|
115
115
|
return false unless !confirm_valid || self.validate.empty?
|
|
116
116
|
Relationship.clear_cached_instances
|
|
117
|
-
zip = write_parts(Zip::OutputStream.new(
|
|
117
|
+
zip = write_parts(Zip::OutputStream.new(StringIO.new, true))
|
|
118
118
|
stream = zip.close_buffer
|
|
119
119
|
stream.rewind
|
|
120
120
|
stream
|
|
@@ -146,7 +146,13 @@ module Axlsx
|
|
|
146
146
|
def validate
|
|
147
147
|
errors = []
|
|
148
148
|
parts.each do |part|
|
|
149
|
-
|
|
149
|
+
unless part[:schema].nil?
|
|
150
|
+
if part[:doc].is_a? String
|
|
151
|
+
errors.concat validate_single_doc(part[:schema], part[:doc])
|
|
152
|
+
else
|
|
153
|
+
errors.concat validate_single_doc(part[:schema], part[:doc].to_xml_string)
|
|
154
|
+
end
|
|
155
|
+
end
|
|
150
156
|
end
|
|
151
157
|
errors
|
|
152
158
|
end
|
|
@@ -159,10 +165,15 @@ module Axlsx
|
|
|
159
165
|
def write_parts(zip)
|
|
160
166
|
p = parts
|
|
161
167
|
p.each do |part|
|
|
168
|
+
#next unless part[:entry] == CORE_PN
|
|
162
169
|
unless part[:doc].nil?
|
|
163
170
|
zip.put_next_entry(zip_entry_for_part(part))
|
|
164
|
-
|
|
165
|
-
|
|
171
|
+
if part[:doc].is_a? String
|
|
172
|
+
entry = ['1.9.2', '1.9.3'].include?(RUBY_VERSION) ? part[:doc].force_encoding('BINARY') : part[:doc]
|
|
173
|
+
zip.puts(entry)
|
|
174
|
+
else
|
|
175
|
+
part[:doc].to_xml_string(zip)
|
|
176
|
+
end
|
|
166
177
|
end
|
|
167
178
|
unless part[:path].nil?
|
|
168
179
|
zip.put_next_entry(zip_entry_for_part(part))
|
|
@@ -194,40 +205,40 @@ module Axlsx
|
|
|
194
205
|
# @private
|
|
195
206
|
def parts
|
|
196
207
|
parts = [
|
|
197
|
-
{:entry => RELS_PN, :doc => relationships
|
|
198
|
-
{:entry => "xl/#{STYLES_PN}", :doc => workbook.styles
|
|
199
|
-
{:entry => CORE_PN, :doc => @core
|
|
200
|
-
{:entry => APP_PN, :doc => @app
|
|
201
|
-
{:entry => WORKBOOK_RELS_PN, :doc => workbook.relationships
|
|
202
|
-
{:entry => CONTENT_TYPES_PN, :doc => content_types
|
|
203
|
-
{:entry => WORKBOOK_PN, :doc => workbook
|
|
208
|
+
{:entry => RELS_PN, :doc => relationships, :schema => RELS_XSD},
|
|
209
|
+
{:entry => "xl/#{STYLES_PN}", :doc => workbook.styles, :schema => SML_XSD},
|
|
210
|
+
{:entry => CORE_PN, :doc => @core, :schema => CORE_XSD},
|
|
211
|
+
{:entry => APP_PN, :doc => @app, :schema => APP_XSD},
|
|
212
|
+
{:entry => WORKBOOK_RELS_PN, :doc => workbook.relationships, :schema => RELS_XSD},
|
|
213
|
+
{:entry => CONTENT_TYPES_PN, :doc => content_types, :schema => CONTENT_TYPES_XSD},
|
|
214
|
+
{:entry => WORKBOOK_PN, :doc => workbook, :schema => SML_XSD}
|
|
204
215
|
]
|
|
205
216
|
|
|
206
217
|
workbook.drawings.each do |drawing|
|
|
207
|
-
parts << {:entry => "xl/#{drawing.rels_pn}", :doc => drawing.relationships
|
|
208
|
-
parts << {:entry => "xl/#{drawing.pn}", :doc => drawing
|
|
218
|
+
parts << {:entry => "xl/#{drawing.rels_pn}", :doc => drawing.relationships, :schema => RELS_XSD}
|
|
219
|
+
parts << {:entry => "xl/#{drawing.pn}", :doc => drawing, :schema => DRAWING_XSD}
|
|
209
220
|
end
|
|
210
221
|
|
|
211
222
|
|
|
212
223
|
workbook.tables.each do |table|
|
|
213
|
-
parts << {:entry => "xl/#{table.pn}", :doc => table
|
|
224
|
+
parts << {:entry => "xl/#{table.pn}", :doc => table, :schema => SML_XSD}
|
|
214
225
|
end
|
|
215
226
|
workbook.pivot_tables.each do |pivot_table|
|
|
216
227
|
cache_definition = pivot_table.cache_definition
|
|
217
|
-
parts << {:entry => "xl/#{pivot_table.rels_pn}", :doc => pivot_table.relationships
|
|
218
|
-
parts << {:entry => "xl/#{pivot_table.pn}", :doc => pivot_table
|
|
219
|
-
parts << {:entry => "xl/#{cache_definition.pn}", :doc => cache_definition
|
|
228
|
+
parts << {:entry => "xl/#{pivot_table.rels_pn}", :doc => pivot_table.relationships, :schema => RELS_XSD}
|
|
229
|
+
parts << {:entry => "xl/#{pivot_table.pn}", :doc => pivot_table} #, :schema => SML_XSD}
|
|
230
|
+
parts << {:entry => "xl/#{cache_definition.pn}", :doc => cache_definition} #, :schema => SML_XSD}
|
|
220
231
|
end
|
|
221
232
|
|
|
222
233
|
workbook.comments.each do|comment|
|
|
223
234
|
if comment.size > 0
|
|
224
|
-
parts << { :entry => "xl/#{comment.pn}", :doc => comment
|
|
225
|
-
parts << { :entry => "xl/#{comment.vml_drawing.pn}", :doc => comment.vml_drawing
|
|
235
|
+
parts << { :entry => "xl/#{comment.pn}", :doc => comment, :schema => SML_XSD }
|
|
236
|
+
parts << { :entry => "xl/#{comment.vml_drawing.pn}", :doc => comment.vml_drawing, :schema => nil }
|
|
226
237
|
end
|
|
227
238
|
end
|
|
228
239
|
|
|
229
240
|
workbook.charts.each do |chart|
|
|
230
|
-
parts << {:entry => "xl/#{chart.pn}", :doc => chart
|
|
241
|
+
parts << {:entry => "xl/#{chart.pn}", :doc => chart, :schema => DRAWING_XSD}
|
|
231
242
|
end
|
|
232
243
|
|
|
233
244
|
workbook.images.each do |image|
|
|
@@ -235,12 +246,12 @@ module Axlsx
|
|
|
235
246
|
end
|
|
236
247
|
|
|
237
248
|
if use_shared_strings
|
|
238
|
-
parts << {:entry => "xl/#{SHARED_STRINGS_PN}", :doc => workbook.shared_strings
|
|
249
|
+
parts << {:entry => "xl/#{SHARED_STRINGS_PN}", :doc => workbook.shared_strings, :schema => SML_XSD}
|
|
239
250
|
end
|
|
240
251
|
|
|
241
252
|
workbook.worksheets.each do |sheet|
|
|
242
|
-
parts << {:entry => "xl/#{sheet.rels_pn}", :doc => sheet.relationships
|
|
243
|
-
parts << {:entry => "xl/#{sheet.pn}", :doc => sheet
|
|
253
|
+
parts << {:entry => "xl/#{sheet.rels_pn}", :doc => sheet.relationships, :schema => RELS_XSD}
|
|
254
|
+
parts << {:entry => "xl/#{sheet.pn}", :doc => sheet, :schema => SML_XSD}
|
|
244
255
|
end
|
|
245
256
|
parts
|
|
246
257
|
end
|
|
@@ -303,7 +314,7 @@ module Axlsx
|
|
|
303
314
|
c_types << Axlsx::Override.new(:PartName => "/xl/#{sheet.pn}",
|
|
304
315
|
:ContentType => WORKSHEET_CT)
|
|
305
316
|
end
|
|
306
|
-
exts = workbook.images.map { |image| image.extname }
|
|
317
|
+
exts = workbook.images.map { |image| image.extname.downcase }
|
|
307
318
|
exts.uniq.each do |ext|
|
|
308
319
|
ct = if ['jpeg', 'jpg'].include?(ext)
|
|
309
320
|
JPEG_CT
|
|
@@ -326,8 +337,8 @@ module Axlsx
|
|
|
326
337
|
# @private
|
|
327
338
|
def base_content_types
|
|
328
339
|
c_types = ContentType.new()
|
|
329
|
-
c_types <<
|
|
330
|
-
c_types <<
|
|
340
|
+
c_types << Default.new(:ContentType => RELS_CT, :Extension => RELS_EX)
|
|
341
|
+
c_types << Default.new(:Extension => XML_EX, :ContentType => XML_CT)
|
|
331
342
|
c_types << Override.new(:PartName => "/#{APP_PN}", :ContentType => APP_CT)
|
|
332
343
|
c_types << Override.new(:PartName => "/#{CORE_PN}", :ContentType => CORE_CT)
|
|
333
344
|
c_types << Override.new(:PartName => "/xl/#{STYLES_PN}", :ContentType => STYLES_CT)
|
|
@@ -102,7 +102,7 @@ module Axlsx
|
|
|
102
102
|
def to_xml_string(str = '')
|
|
103
103
|
h = self.instance_values.reject{|k, _| k == "source_obj"}
|
|
104
104
|
str << '<Relationship '
|
|
105
|
-
str << h.map { |key, value| '' << key.to_s << '="' << Axlsx::coder.encode(value.to_s) << '"'}.join(' ')
|
|
105
|
+
str << (h.map { |key, value| '' << key.to_s << '="' << Axlsx::coder.encode(value.to_s) << '"'}.join(' '))
|
|
106
106
|
str << '/>'
|
|
107
107
|
end
|
|
108
108
|
|
|
@@ -15,12 +15,12 @@ require 'axlsx/rels/relationship.rb'
|
|
|
15
15
|
# @see Relationship#source_obj
|
|
16
16
|
# @return [Relationship]
|
|
17
17
|
def for(source_obj)
|
|
18
|
-
|
|
18
|
+
find{ |rel| rel.source_obj == source_obj }
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
def to_xml_string(str = '')
|
|
22
22
|
str << '<?xml version="1.0" encoding="UTF-8"?>'
|
|
23
|
-
str << '<Relationships xmlns="' << RELS_R << '">'
|
|
23
|
+
str << ('<Relationships xmlns="' << RELS_R << '">')
|
|
24
24
|
each{ |rel| rel.to_xml_string(str) }
|
|
25
25
|
str << '</Relationships>'
|
|
26
26
|
end
|
|
@@ -62,9 +62,9 @@ module Axlsx
|
|
|
62
62
|
# @param [String] str
|
|
63
63
|
# @return [String]
|
|
64
64
|
def to_xml_string(str = '')
|
|
65
|
-
str << '<' << @name.to_s << ' style="' << @style.to_s << '">'
|
|
65
|
+
str << ('<' << @name.to_s << ' style="' << @style.to_s << '">')
|
|
66
66
|
@color.to_xml_string(str) if @color.is_a?(Color)
|
|
67
|
-
str << '</' << @name.to_s << '>'
|
|
67
|
+
str << ('</' << @name.to_s << '>')
|
|
68
68
|
end
|
|
69
69
|
|
|
70
70
|
end
|
|
@@ -140,7 +140,7 @@ module Axlsx
|
|
|
140
140
|
def to_xml_string(str = '')
|
|
141
141
|
str << '<font>'
|
|
142
142
|
instance_values.each do |k, v|
|
|
143
|
-
v.is_a?(Color) ? v.to_xml_string(str) : (str << '<' << k.to_s << ' val="' << v.to_s << '"/>')
|
|
143
|
+
v.is_a?(Color) ? v.to_xml_string(str) : (str << ('<' << k.to_s << ' val="' << Axlsx.booleanize(v).to_s << '"/>'))
|
|
144
144
|
end
|
|
145
145
|
str << '</font>'
|
|
146
146
|
end
|
|
@@ -29,7 +29,7 @@ module Axlsx
|
|
|
29
29
|
# @param [String] str
|
|
30
30
|
# @return [String]
|
|
31
31
|
def to_xml_string(str = '')
|
|
32
|
-
str << '<stop position="' << position.to_s << '">'
|
|
32
|
+
str << ('<stop position="' << position.to_s << '">')
|
|
33
33
|
self.color.to_xml_string(str)
|
|
34
34
|
str << '</stop>'
|
|
35
35
|
end
|
|
@@ -59,7 +59,7 @@ module Axlsx
|
|
|
59
59
|
# @param [String] str
|
|
60
60
|
# @return [String]
|
|
61
61
|
def to_xml_string(str = '')
|
|
62
|
-
str << '<patternFill patternType="' << patternType.to_s << '">'
|
|
62
|
+
str << ('<patternFill patternType="' << patternType.to_s << '">')
|
|
63
63
|
if fgColor.is_a?(Color)
|
|
64
64
|
fgColor.to_xml_string str, "fgColor"
|
|
65
65
|
end
|
|
@@ -151,7 +151,7 @@ module Axlsx
|
|
|
151
151
|
# ws = p.workbook.add_worksheet
|
|
152
152
|
#
|
|
153
153
|
# # black text on a white background at 14pt with thin borders!
|
|
154
|
-
# title = ws.
|
|
154
|
+
# title = ws.styles.add_style(:bg_color => "FFFF0000", :fg_color=>"#FF000000", :sz=>14, :border=> {:style => :thin, :color => "FFFF0000"}
|
|
155
155
|
#
|
|
156
156
|
# ws.add_row ["Least Popular Pets"]
|
|
157
157
|
# ws.add_row ["", "Dry Skinned Reptiles", "Bald Cats", "Violent Parrots"], :style=>title
|
|
@@ -168,18 +168,18 @@ module Axlsx
|
|
|
168
168
|
# ws = p.workbook.add_worksheet
|
|
169
169
|
#
|
|
170
170
|
# # define your styles
|
|
171
|
-
# title = ws.
|
|
171
|
+
# title = ws.styles.add_style(:bg_color => "FFFF0000",
|
|
172
172
|
# :fg_color=>"#FF000000",
|
|
173
173
|
# :border=>Axlsx::STYLE_THIN_BORDER,
|
|
174
174
|
# :alignment=>{:horizontal => :center})
|
|
175
175
|
#
|
|
176
|
-
# date_time = ws.
|
|
176
|
+
# date_time = ws.styles.add_style(:num_fmt => Axlsx::NUM_FMT_YYYYMMDDHHMMSS,
|
|
177
177
|
# :border=>Axlsx::STYLE_THIN_BORDER)
|
|
178
178
|
#
|
|
179
|
-
# percent = ws.
|
|
179
|
+
# percent = ws.styles.add_style(:num_fmt => Axlsx::NUM_FMT_PERCENT,
|
|
180
180
|
# :border=>Axlsx::STYLE_THIN_BORDER)
|
|
181
181
|
#
|
|
182
|
-
# currency = ws.
|
|
182
|
+
# currency = ws.styles.add_style(:format_code=>"¥#,##0;[Red]¥-#,##0",
|
|
183
183
|
# :border=>Axlsx::STYLE_THIN_BORDER)
|
|
184
184
|
#
|
|
185
185
|
# # build your rows
|
|
@@ -362,7 +362,7 @@ module Axlsx
|
|
|
362
362
|
# @param [String] str
|
|
363
363
|
# @return [String]
|
|
364
364
|
def to_xml_string(str = '')
|
|
365
|
-
str << '<styleSheet xmlns="' << XML_NS << '">'
|
|
365
|
+
str << ('<styleSheet xmlns="' << XML_NS << '">')
|
|
366
366
|
[:numFmts, :fonts, :fills, :borders, :cellStyleXfs, :cellXfs, :cellStyles, :dxfs, :tableStyles].each do |key|
|
|
367
367
|
self.instance_values[key.to_s].to_xml_string(str) unless self.instance_values[key.to_s].nil?
|
|
368
368
|
end
|
data/lib/axlsx/util/accessors.rb
CHANGED
|
@@ -19,7 +19,7 @@ module Axlsx
|
|
|
19
19
|
# @param [Array] symbols An array of symbols representing the
|
|
20
20
|
# names of the attributes you will add to your class.
|
|
21
21
|
def string_attr_accessor(*symbols)
|
|
22
|
-
validated_attr_accessor(symbols,
|
|
22
|
+
validated_attr_accessor(symbols, :validate_string)
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
|
|
@@ -27,25 +27,25 @@ module Axlsx
|
|
|
27
27
|
# @param [Array] symbols An array of symbols representing the
|
|
28
28
|
# names of the attributes you will add to your class
|
|
29
29
|
def unsigned_int_attr_accessor(*symbols)
|
|
30
|
-
validated_attr_accessor(symbols,
|
|
30
|
+
validated_attr_accessor(symbols, :validate_unsigned_int)
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
# Creates one or more float (double?) attr_accessors
|
|
34
34
|
# @param [Array] symbols An array of symbols representing the
|
|
35
35
|
# names of the attributes you will add to your class
|
|
36
36
|
def float_attr_accessor(*symbols)
|
|
37
|
-
validated_attr_accessor(symbols,
|
|
37
|
+
validated_attr_accessor(symbols, :validate_float)
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
# Creates on or more boolean validated attr_accessors
|
|
41
41
|
# @param [Array] symbols An array of symbols representing the
|
|
42
42
|
# names of the attributes you will add to your class.
|
|
43
43
|
def boolean_attr_accessor(*symbols)
|
|
44
|
-
validated_attr_accessor(symbols,
|
|
44
|
+
validated_attr_accessor(symbols, :validate_boolean)
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
# Template for defining validated write accessors
|
|
48
|
-
SETTER = "def %s=(value) Axlsx::%s(value); @%s = value; end"
|
|
48
|
+
SETTER = "def %s=(value) Axlsx::%s(value); @%s = value; end".freeze
|
|
49
49
|
|
|
50
50
|
# Creates the reader and writer access methods
|
|
51
51
|
# @param [Array] symbols The names of the attributes to create
|
|
@@ -55,7 +55,7 @@ module Axlsx
|
|
|
55
55
|
def validated_attr_accessor(symbols, validator)
|
|
56
56
|
symbols.each do |symbol|
|
|
57
57
|
attr_reader symbol
|
|
58
|
-
module_eval(SETTER % [symbol
|
|
58
|
+
module_eval(SETTER % [symbol, validator, symbol], __FILE__, __LINE__)
|
|
59
59
|
end
|
|
60
60
|
end
|
|
61
61
|
end
|
data/lib/axlsx/util/constants.rb
CHANGED
|
@@ -1,263 +1,263 @@
|
|
|
1
1
|
module Axlsx
|
|
2
2
|
|
|
3
3
|
# XML Encoding
|
|
4
|
-
ENCODING = "UTF-8"
|
|
4
|
+
ENCODING = "UTF-8".freeze
|
|
5
5
|
|
|
6
6
|
# spreadsheetML namespace
|
|
7
|
-
XML_NS = "http://schemas.openxmlformats.org/spreadsheetml/2006/main"
|
|
7
|
+
XML_NS = "http://schemas.openxmlformats.org/spreadsheetml/2006/main".freeze
|
|
8
8
|
|
|
9
9
|
# content-types namespace
|
|
10
|
-
XML_NS_T = "http://schemas.openxmlformats.org/package/2006/content-types"
|
|
10
|
+
XML_NS_T = "http://schemas.openxmlformats.org/package/2006/content-types".freeze
|
|
11
11
|
|
|
12
12
|
# extended-properties namespace
|
|
13
|
-
APP_NS = "http://schemas.openxmlformats.org/officeDocument/2006/extended-properties"
|
|
13
|
+
APP_NS = "http://schemas.openxmlformats.org/officeDocument/2006/extended-properties".freeze
|
|
14
14
|
|
|
15
15
|
# doc props namespace
|
|
16
|
-
APP_NS_VT = "http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes"
|
|
16
|
+
APP_NS_VT = "http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes".freeze
|
|
17
17
|
|
|
18
18
|
# core properties namespace
|
|
19
|
-
CORE_NS = "http://schemas.openxmlformats.org/package/2006/metadata/core-properties"
|
|
19
|
+
CORE_NS = "http://schemas.openxmlformats.org/package/2006/metadata/core-properties".freeze
|
|
20
20
|
|
|
21
21
|
# dc elements (core) namespace
|
|
22
|
-
CORE_NS_DC = "http://purl.org/dc/elements/1.1/"
|
|
22
|
+
CORE_NS_DC = "http://purl.org/dc/elements/1.1/".freeze
|
|
23
23
|
|
|
24
24
|
# dcmit (core) namespcace
|
|
25
|
-
CORE_NS_DCMIT = "http://purl.org/dc/dcmitype/"
|
|
25
|
+
CORE_NS_DCMIT = "http://purl.org/dc/dcmitype/".freeze
|
|
26
26
|
|
|
27
27
|
# dc terms namespace
|
|
28
|
-
CORE_NS_DCT = "http://purl.org/dc/terms/"
|
|
28
|
+
CORE_NS_DCT = "http://purl.org/dc/terms/".freeze
|
|
29
29
|
|
|
30
30
|
# xml schema namespace
|
|
31
|
-
CORE_NS_XSI = "http://www.w3.org/2001/XMLSchema-instance"
|
|
31
|
+
CORE_NS_XSI = "http://www.w3.org/2001/XMLSchema-instance".freeze
|
|
32
32
|
|
|
33
33
|
# Digital signature namespace
|
|
34
|
-
DIGITAL_SIGNATURE_NS = "http://schemas.openxmlformats.org/package/2006/digital-signature"
|
|
34
|
+
DIGITAL_SIGNATURE_NS = "http://schemas.openxmlformats.org/package/2006/digital-signature".freeze
|
|
35
35
|
|
|
36
36
|
# spreadsheet drawing namespace
|
|
37
|
-
XML_NS_XDR = "http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing"
|
|
37
|
+
XML_NS_XDR = "http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing".freeze
|
|
38
38
|
|
|
39
39
|
# drawing namespace
|
|
40
|
-
XML_NS_A = "http://schemas.openxmlformats.org/drawingml/2006/main"
|
|
40
|
+
XML_NS_A = "http://schemas.openxmlformats.org/drawingml/2006/main".freeze
|
|
41
41
|
|
|
42
42
|
# chart namespace
|
|
43
|
-
XML_NS_C = "http://schemas.openxmlformats.org/drawingml/2006/chart"
|
|
43
|
+
XML_NS_C = "http://schemas.openxmlformats.org/drawingml/2006/chart".freeze
|
|
44
44
|
|
|
45
45
|
# relationships namespace
|
|
46
|
-
XML_NS_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships"
|
|
46
|
+
XML_NS_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships".freeze
|
|
47
47
|
|
|
48
48
|
# relationships name space
|
|
49
|
-
RELS_R = "http://schemas.openxmlformats.org/package/2006/relationships"
|
|
49
|
+
RELS_R = "http://schemas.openxmlformats.org/package/2006/relationships".freeze
|
|
50
50
|
|
|
51
51
|
# table rels namespace
|
|
52
|
-
TABLE_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/table"
|
|
52
|
+
TABLE_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/table".freeze
|
|
53
53
|
|
|
54
54
|
# pivot table rels namespace
|
|
55
|
-
PIVOT_TABLE_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotTable"
|
|
55
|
+
PIVOT_TABLE_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotTable".freeze
|
|
56
56
|
|
|
57
57
|
# pivot table cache definition namespace
|
|
58
|
-
PIVOT_TABLE_CACHE_DEFINITION_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCacheDefinition"
|
|
58
|
+
PIVOT_TABLE_CACHE_DEFINITION_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCacheDefinition".freeze
|
|
59
59
|
|
|
60
60
|
# workbook rels namespace
|
|
61
|
-
WORKBOOK_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument"
|
|
61
|
+
WORKBOOK_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument".freeze
|
|
62
62
|
|
|
63
63
|
# worksheet rels namespace
|
|
64
|
-
WORKSHEET_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet"
|
|
64
|
+
WORKSHEET_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet".freeze
|
|
65
65
|
|
|
66
66
|
# app rels namespace
|
|
67
|
-
APP_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties"
|
|
67
|
+
APP_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties".freeze
|
|
68
68
|
|
|
69
69
|
# core rels namespace
|
|
70
|
-
CORE_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/metadata/core-properties"
|
|
70
|
+
CORE_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/metadata/core-properties".freeze
|
|
71
71
|
|
|
72
72
|
# digital signature rels namespace
|
|
73
|
-
DIGITAL_SIGNATURE_R = "http://schemas.openxmlformats.org/package/2006/relationships/digital- signature/signature"
|
|
73
|
+
DIGITAL_SIGNATURE_R = "http://schemas.openxmlformats.org/package/2006/relationships/digital- signature/signature".freeze
|
|
74
74
|
|
|
75
75
|
# styles rels namespace
|
|
76
|
-
STYLES_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles"
|
|
76
|
+
STYLES_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles".freeze
|
|
77
77
|
|
|
78
78
|
# shared strings namespace
|
|
79
|
-
SHARED_STRINGS_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings"
|
|
79
|
+
SHARED_STRINGS_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings".freeze
|
|
80
80
|
|
|
81
81
|
# drawing rels namespace
|
|
82
|
-
DRAWING_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing"
|
|
82
|
+
DRAWING_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing".freeze
|
|
83
83
|
|
|
84
84
|
# chart rels namespace
|
|
85
|
-
CHART_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart"
|
|
85
|
+
CHART_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart".freeze
|
|
86
86
|
|
|
87
87
|
# image rels namespace
|
|
88
|
-
IMAGE_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"
|
|
88
|
+
IMAGE_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image".freeze
|
|
89
89
|
|
|
90
90
|
# hyperlink rels namespace
|
|
91
|
-
HYPERLINK_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink"
|
|
91
|
+
HYPERLINK_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink".freeze
|
|
92
92
|
|
|
93
93
|
# comment rels namespace
|
|
94
|
-
COMMENT_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments"
|
|
94
|
+
COMMENT_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments".freeze
|
|
95
95
|
|
|
96
96
|
# comment relation for nil target
|
|
97
|
-
COMMENT_R_NULL = "http://purl.oclc.org/ooxml/officeDocument/relationships/comments"
|
|
97
|
+
COMMENT_R_NULL = "http://purl.oclc.org/ooxml/officeDocument/relationships/comments".freeze
|
|
98
98
|
|
|
99
99
|
#vml drawing relation namespace
|
|
100
100
|
VML_DRAWING_R = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing'
|
|
101
101
|
|
|
102
102
|
# VML Drawing content type
|
|
103
|
-
VML_DRAWING_CT = "application/vnd.openxmlformats-officedocument.vmlDrawing"
|
|
103
|
+
VML_DRAWING_CT = "application/vnd.openxmlformats-officedocument.vmlDrawing".freeze
|
|
104
104
|
|
|
105
105
|
# table content type
|
|
106
|
-
TABLE_CT = "application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml"
|
|
106
|
+
TABLE_CT = "application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml".freeze
|
|
107
107
|
|
|
108
108
|
# pivot table content type
|
|
109
|
-
PIVOT_TABLE_CT = "application/vnd.openxmlformats-officedocument.spreadsheetml.pivotTable+xml"
|
|
109
|
+
PIVOT_TABLE_CT = "application/vnd.openxmlformats-officedocument.spreadsheetml.pivotTable+xml".freeze
|
|
110
110
|
|
|
111
111
|
# pivot table cache definition content type
|
|
112
|
-
PIVOT_TABLE_CACHE_DEFINITION_CT = "application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheDefinition+xml"
|
|
112
|
+
PIVOT_TABLE_CACHE_DEFINITION_CT = "application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheDefinition+xml".freeze
|
|
113
113
|
|
|
114
114
|
# workbook content type
|
|
115
|
-
WORKBOOK_CT = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"
|
|
115
|
+
WORKBOOK_CT = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml".freeze
|
|
116
116
|
|
|
117
117
|
# app content type
|
|
118
|
-
APP_CT = "application/vnd.openxmlformats-officedocument.extended-properties+xml"
|
|
118
|
+
APP_CT = "application/vnd.openxmlformats-officedocument.extended-properties+xml".freeze
|
|
119
119
|
|
|
120
120
|
# rels content type
|
|
121
|
-
RELS_CT = "application/vnd.openxmlformats-package.relationships+xml"
|
|
121
|
+
RELS_CT = "application/vnd.openxmlformats-package.relationships+xml".freeze
|
|
122
122
|
|
|
123
123
|
# styles content type
|
|
124
|
-
STYLES_CT = "application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml"
|
|
124
|
+
STYLES_CT = "application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml".freeze
|
|
125
125
|
|
|
126
126
|
# xml content type
|
|
127
|
-
XML_CT = "application/xml"
|
|
127
|
+
XML_CT = "application/xml".freeze
|
|
128
128
|
|
|
129
129
|
# worksheet content type
|
|
130
|
-
WORKSHEET_CT = "application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"
|
|
130
|
+
WORKSHEET_CT = "application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml".freeze
|
|
131
131
|
|
|
132
132
|
# shared strings content type
|
|
133
|
-
SHARED_STRINGS_CT = "application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml"
|
|
133
|
+
SHARED_STRINGS_CT = "application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml".freeze
|
|
134
134
|
|
|
135
135
|
# core content type
|
|
136
|
-
CORE_CT = "application/vnd.openxmlformats-package.core-properties+xml"
|
|
136
|
+
CORE_CT = "application/vnd.openxmlformats-package.core-properties+xml".freeze
|
|
137
137
|
|
|
138
138
|
# digital signature xml content type
|
|
139
|
-
DIGITAL_SIGNATURE_XML_CT = "application/vnd.openxmlformats-package.digital-signature-xmlsignature+xml"
|
|
139
|
+
DIGITAL_SIGNATURE_XML_CT = "application/vnd.openxmlformats-package.digital-signature-xmlsignature+xml".freeze
|
|
140
140
|
|
|
141
141
|
# digital signature origin content type
|
|
142
|
-
DIGITAL_SIGNATURE_ORIGIN_CT = "application/vnd.openxmlformats-package.digital-signature-origin"
|
|
142
|
+
DIGITAL_SIGNATURE_ORIGIN_CT = "application/vnd.openxmlformats-package.digital-signature-origin".freeze
|
|
143
143
|
|
|
144
144
|
# digital signature certificate content type
|
|
145
|
-
DIGITAL_SIGNATURE_CERTIFICATE_CT = "application/vnd.openxmlformats-package.digital-signature-certificate"
|
|
145
|
+
DIGITAL_SIGNATURE_CERTIFICATE_CT = "application/vnd.openxmlformats-package.digital-signature-certificate".freeze
|
|
146
146
|
|
|
147
147
|
# chart content type
|
|
148
|
-
CHART_CT = "application/vnd.openxmlformats-officedocument.drawingml.chart+xml"
|
|
148
|
+
CHART_CT = "application/vnd.openxmlformats-officedocument.drawingml.chart+xml".freeze
|
|
149
149
|
|
|
150
150
|
# comments content type
|
|
151
|
-
COMMENT_CT = "application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml"
|
|
151
|
+
COMMENT_CT = "application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml".freeze
|
|
152
152
|
|
|
153
153
|
# jpeg content type
|
|
154
|
-
JPEG_CT = "image/jpeg"
|
|
154
|
+
JPEG_CT = "image/jpeg".freeze
|
|
155
155
|
|
|
156
156
|
# gif content type
|
|
157
|
-
GIF_CT = "image/gif"
|
|
157
|
+
GIF_CT = "image/gif".freeze
|
|
158
158
|
|
|
159
159
|
# png content type
|
|
160
|
-
PNG_CT = "image/png"
|
|
160
|
+
PNG_CT = "image/png".freeze
|
|
161
161
|
|
|
162
162
|
#drawing content type
|
|
163
|
-
DRAWING_CT = "application/vnd.openxmlformats-officedocument.drawing+xml"
|
|
163
|
+
DRAWING_CT = "application/vnd.openxmlformats-officedocument.drawing+xml".freeze
|
|
164
164
|
|
|
165
165
|
|
|
166
166
|
# xml content type extensions
|
|
167
|
-
XML_EX = "xml"
|
|
167
|
+
XML_EX = "xml".freeze
|
|
168
168
|
|
|
169
169
|
# jpeg extension
|
|
170
|
-
JPEG_EX = "jpeg"
|
|
170
|
+
JPEG_EX = "jpeg".freeze
|
|
171
171
|
|
|
172
172
|
# gif extension
|
|
173
|
-
GIF_EX = "gif"
|
|
173
|
+
GIF_EX = "gif".freeze
|
|
174
174
|
|
|
175
175
|
# png extension
|
|
176
|
-
PNG_EX = "png"
|
|
176
|
+
PNG_EX = "png".freeze
|
|
177
177
|
|
|
178
178
|
# rels content type extension
|
|
179
|
-
RELS_EX = "rels"
|
|
179
|
+
RELS_EX = "rels".freeze
|
|
180
180
|
|
|
181
181
|
# workbook part
|
|
182
|
-
WORKBOOK_PN = "xl/workbook.xml"
|
|
182
|
+
WORKBOOK_PN = "xl/workbook.xml".freeze
|
|
183
183
|
|
|
184
184
|
# styles part
|
|
185
|
-
STYLES_PN = "styles.xml"
|
|
185
|
+
STYLES_PN = "styles.xml".freeze
|
|
186
186
|
|
|
187
187
|
# shared_strings part
|
|
188
|
-
SHARED_STRINGS_PN = "sharedStrings.xml"
|
|
188
|
+
SHARED_STRINGS_PN = "sharedStrings.xml".freeze
|
|
189
189
|
|
|
190
190
|
# app part
|
|
191
|
-
APP_PN = "docProps/app.xml"
|
|
191
|
+
APP_PN = "docProps/app.xml".freeze
|
|
192
192
|
|
|
193
193
|
# core part
|
|
194
|
-
CORE_PN = "docProps/core.xml"
|
|
194
|
+
CORE_PN = "docProps/core.xml".freeze
|
|
195
195
|
|
|
196
196
|
# content types part
|
|
197
|
-
CONTENT_TYPES_PN = "[Content_Types].xml"
|
|
197
|
+
CONTENT_TYPES_PN = "[Content_Types].xml".freeze
|
|
198
198
|
|
|
199
199
|
# rels part
|
|
200
|
-
RELS_PN = "_rels/.rels"
|
|
200
|
+
RELS_PN = "_rels/.rels".freeze
|
|
201
201
|
|
|
202
202
|
# workbook rels part
|
|
203
|
-
WORKBOOK_RELS_PN = "xl/_rels/workbook.xml.rels"
|
|
203
|
+
WORKBOOK_RELS_PN = "xl/_rels/workbook.xml.rels".freeze
|
|
204
204
|
|
|
205
205
|
# worksheet part
|
|
206
|
-
WORKSHEET_PN = "worksheets/sheet%d.xml"
|
|
206
|
+
WORKSHEET_PN = "worksheets/sheet%d.xml".freeze
|
|
207
207
|
|
|
208
208
|
# worksheet rels part
|
|
209
|
-
WORKSHEET_RELS_PN = "worksheets/_rels/sheet%d.xml.rels"
|
|
209
|
+
WORKSHEET_RELS_PN = "worksheets/_rels/sheet%d.xml.rels".freeze
|
|
210
210
|
|
|
211
211
|
# drawing part
|
|
212
|
-
DRAWING_PN = "drawings/drawing%d.xml"
|
|
212
|
+
DRAWING_PN = "drawings/drawing%d.xml".freeze
|
|
213
213
|
|
|
214
214
|
# drawing rels part
|
|
215
|
-
DRAWING_RELS_PN = "drawings/_rels/drawing%d.xml.rels"
|
|
215
|
+
DRAWING_RELS_PN = "drawings/_rels/drawing%d.xml.rels".freeze
|
|
216
216
|
|
|
217
217
|
# vml drawing part
|
|
218
|
-
VML_DRAWING_PN = "drawings/vmlDrawing%d.vml"
|
|
218
|
+
VML_DRAWING_PN = "drawings/vmlDrawing%d.vml".freeze
|
|
219
219
|
|
|
220
220
|
# drawing part
|
|
221
|
-
TABLE_PN = "tables/table%d.xml"
|
|
221
|
+
TABLE_PN = "tables/table%d.xml".freeze
|
|
222
222
|
|
|
223
223
|
# pivot table parts
|
|
224
|
-
PIVOT_TABLE_PN = "pivotTables/pivotTable%d.xml"
|
|
224
|
+
PIVOT_TABLE_PN = "pivotTables/pivotTable%d.xml".freeze
|
|
225
225
|
|
|
226
226
|
# pivot table cache definition part name
|
|
227
|
-
PIVOT_TABLE_CACHE_DEFINITION_PN = "pivotCache/pivotCacheDefinition%d.xml"
|
|
227
|
+
PIVOT_TABLE_CACHE_DEFINITION_PN = "pivotCache/pivotCacheDefinition%d.xml".freeze
|
|
228
228
|
|
|
229
229
|
# pivot table rels parts
|
|
230
|
-
PIVOT_TABLE_RELS_PN = "pivotTables/_rels/pivotTable%d.xml.rels"
|
|
230
|
+
PIVOT_TABLE_RELS_PN = "pivotTables/_rels/pivotTable%d.xml.rels".freeze
|
|
231
231
|
|
|
232
232
|
# chart part
|
|
233
|
-
CHART_PN = "charts/chart%d.xml"
|
|
233
|
+
CHART_PN = "charts/chart%d.xml".freeze
|
|
234
234
|
|
|
235
235
|
# chart part
|
|
236
|
-
IMAGE_PN = "media/image%d.%s"
|
|
236
|
+
IMAGE_PN = "media/image%d.%s".freeze
|
|
237
237
|
|
|
238
238
|
# comment part
|
|
239
|
-
COMMENT_PN = "comments%d.xml"
|
|
239
|
+
COMMENT_PN = "comments%d.xml".freeze
|
|
240
240
|
|
|
241
241
|
# location of schema files for validation
|
|
242
|
-
SCHEMA_BASE = File.dirname(__FILE__)+'/../../schema/'
|
|
242
|
+
SCHEMA_BASE = (File.dirname(__FILE__)+'/../../schema/').freeze
|
|
243
243
|
|
|
244
244
|
# App validation schema
|
|
245
|
-
APP_XSD = SCHEMA_BASE + "shared-documentPropertiesExtended.xsd"
|
|
245
|
+
APP_XSD = (SCHEMA_BASE + "shared-documentPropertiesExtended.xsd").freeze
|
|
246
246
|
|
|
247
247
|
# core validation schema
|
|
248
|
-
CORE_XSD = SCHEMA_BASE + "opc-coreProperties.xsd"
|
|
248
|
+
CORE_XSD = (SCHEMA_BASE + "opc-coreProperties.xsd").freeze
|
|
249
249
|
|
|
250
250
|
# content types validation schema
|
|
251
|
-
CONTENT_TYPES_XSD = SCHEMA_BASE + "opc-contentTypes.xsd"
|
|
251
|
+
CONTENT_TYPES_XSD = (SCHEMA_BASE + "opc-contentTypes.xsd").freeze
|
|
252
252
|
|
|
253
253
|
# rels validation schema
|
|
254
|
-
RELS_XSD = SCHEMA_BASE + "opc-relationships.xsd"
|
|
254
|
+
RELS_XSD = (SCHEMA_BASE + "opc-relationships.xsd").freeze
|
|
255
255
|
|
|
256
256
|
# spreadsheetML validation schema
|
|
257
|
-
SML_XSD = SCHEMA_BASE + "sml.xsd"
|
|
257
|
+
SML_XSD = (SCHEMA_BASE + "sml.xsd").freeze
|
|
258
258
|
|
|
259
259
|
# drawing validation schema
|
|
260
|
-
DRAWING_XSD = SCHEMA_BASE + "dml-spreadsheetDrawing.xsd"
|
|
260
|
+
DRAWING_XSD = (SCHEMA_BASE + "dml-spreadsheetDrawing.xsd").freeze
|
|
261
261
|
|
|
262
262
|
# number format id for pecentage formatting using the default formatting id.
|
|
263
263
|
NUM_FMT_PERCENT = 9
|
|
@@ -275,37 +275,37 @@ module Axlsx
|
|
|
275
275
|
STYLE_DATE = 2
|
|
276
276
|
|
|
277
277
|
# error messages RestrictionValidor
|
|
278
|
-
ERR_RESTRICTION = "Invalid Data: %s. %s must be one of %s."
|
|
278
|
+
ERR_RESTRICTION = "Invalid Data: %s. %s must be one of %s.".freeze
|
|
279
279
|
|
|
280
280
|
# error message DataTypeValidator
|
|
281
|
-
ERR_TYPE = "Invalid Data %s for %s. must be %s."
|
|
281
|
+
ERR_TYPE = "Invalid Data %s for %s. must be %s.".freeze
|
|
282
282
|
|
|
283
283
|
# error message for RegexValidator
|
|
284
|
-
ERR_REGEX = "Invalid Data. %s does not match %s."
|
|
284
|
+
ERR_REGEX = "Invalid Data. %s does not match %s.".freeze
|
|
285
285
|
|
|
286
286
|
# error message for RangeValidator
|
|
287
|
-
ERR_RANGE = "Invalid Data. %s must be between %s and %s, (inclusive:%s) you gave: %s"
|
|
287
|
+
ERR_RANGE = "Invalid Data. %s must be between %s and %s, (inclusive:%s) you gave: %s".freeze
|
|
288
288
|
|
|
289
289
|
# error message for sheets that use a name which is longer than 31 bytes
|
|
290
|
-
ERR_SHEET_NAME_TOO_LONG = "Your worksheet name '%s' is too long. Worksheet names must be 31 characters (bytes) or less"
|
|
290
|
+
ERR_SHEET_NAME_TOO_LONG = "Your worksheet name '%s' is too long. Worksheet names must be 31 characters (bytes) or less".freeze
|
|
291
291
|
|
|
292
292
|
# error message for sheets that use a name which include invalid characters
|
|
293
|
-
ERR_SHEET_NAME_CHARACTER_FORBIDDEN = "Your worksheet name '%s' contains a character which is not allowed by MS Excel and will cause repair warnings. Please change the name of your sheet."
|
|
293
|
+
ERR_SHEET_NAME_CHARACTER_FORBIDDEN = "Your worksheet name '%s' contains a character which is not allowed by MS Excel and will cause repair warnings. Please change the name of your sheet.".freeze
|
|
294
294
|
|
|
295
295
|
# error message for duplicate sheet names
|
|
296
|
-
ERR_DUPLICATE_SHEET_NAME = "There is already a worksheet in this workbook named '%s'. Please use a unique name"
|
|
296
|
+
ERR_DUPLICATE_SHEET_NAME = "There is already a worksheet in this workbook named '%s'. Please use a unique name".freeze
|
|
297
297
|
|
|
298
298
|
# error message when user does not provide color and or style options for border in Style#add_sytle
|
|
299
|
-
ERR_INVALID_BORDER_OPTIONS = "border hash must include both style and color. e.g. :border => { :color => 'FF000000', :style => :thin }. You provided: %s"
|
|
299
|
+
ERR_INVALID_BORDER_OPTIONS = "border hash must include both style and color. e.g. :border => { :color => 'FF000000', :style => :thin }. You provided: %s".freeze
|
|
300
300
|
|
|
301
301
|
# error message for invalid border id reference
|
|
302
|
-
ERR_INVALID_BORDER_ID = "The border id you specified (%s) does not exist. Please add a border with Style#add_style before referencing its index."
|
|
302
|
+
ERR_INVALID_BORDER_ID = "The border id you specified (%s) does not exist. Please add a border with Style#add_style before referencing its index.".freeze
|
|
303
303
|
|
|
304
304
|
# error message for invalid angles
|
|
305
|
-
ERR_ANGLE = "Angles must be a value between -90 and 90. You provided: %s"
|
|
305
|
+
ERR_ANGLE = "Angles must be a value between -90 and 90. You provided: %s".freeze
|
|
306
306
|
|
|
307
307
|
# error message for non 'integerish' value
|
|
308
|
-
ERR_INTEGERISH = "You value must be, or be castable via to_i, an Integer. You provided %s"
|
|
308
|
+
ERR_INTEGERISH = "You value must be, or be castable via to_i, an Integer. You provided %s".freeze
|
|
309
309
|
|
|
310
310
|
# Regex to match forbidden control characters
|
|
311
311
|
# The following will be automatically stripped from worksheets.
|
|
@@ -383,10 +383,15 @@ module Axlsx
|
|
|
383
383
|
# x0D Carriage Return (Cr)
|
|
384
384
|
# x09 Character Tabulation
|
|
385
385
|
# @see http://www.codetable.net/asciikeycodes
|
|
386
|
-
pattern = "
|
|
387
|
-
pattern= pattern.respond_to?(:encode) ? pattern.encode('UTF-8') : pattern
|
|
388
|
-
|
|
386
|
+
pattern = "\x0-\x08\x0B\x0C\x0E-\x1F"
|
|
387
|
+
pattern = pattern.respond_to?(:encode) ? pattern.encode('UTF-8') : pattern
|
|
388
|
+
|
|
389
389
|
# The regular expression used to remove control characters from worksheets
|
|
390
|
-
|
|
391
|
-
|
|
390
|
+
CONTROL_CHARS = pattern.freeze
|
|
391
|
+
|
|
392
|
+
ISO_8601_REGEX = /\A(-?(?:[1-9][0-9]*)?[0-9]{4})-(1[0-2]|0[1-9])-(3[0-1]|0[1-9]|[1-2][0-9])T(2[0-3]|[0-1][0-9]):([0-5][0-9]):([0-5][0-9])(\.[0-9]+)?(Z|[+-](?:2[0-3]|[0-1][0-9]):[0-5][0-9])?\Z/.freeze
|
|
393
|
+
|
|
394
|
+
FLOAT_REGEX = /\A[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?\Z/.freeze
|
|
395
|
+
|
|
396
|
+
NUMERIC_REGEX = /\A[+-]?\d+?\Z/.freeze
|
|
392
397
|
end
|