rubyXL 1.2.10 → 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (101) hide show
  1. data/Gemfile +14 -10
  2. data/Gemfile.lock +80 -21
  3. data/LICENSE.txt +1 -1
  4. data/README.rdoc +88 -82
  5. data/Rakefile +7 -2
  6. data/VERSION +1 -1
  7. data/lib/rubyXL.rb +13 -7
  8. data/lib/rubyXL/cell.rb +108 -268
  9. data/lib/rubyXL/generic_storage.rb +40 -0
  10. data/lib/rubyXL/objects/border.rb +66 -0
  11. data/lib/rubyXL/objects/calculation_chain.rb +28 -0
  12. data/lib/rubyXL/objects/cell_style.rb +75 -0
  13. data/lib/rubyXL/objects/color.rb +25 -0
  14. data/lib/rubyXL/objects/column_range.rb +74 -0
  15. data/lib/rubyXL/objects/container_nodes.rb +122 -0
  16. data/lib/rubyXL/objects/data_validation.rb +43 -0
  17. data/lib/rubyXL/objects/document_properties.rb +76 -0
  18. data/lib/rubyXL/objects/extensions.rb +36 -0
  19. data/lib/rubyXL/objects/fill.rb +57 -0
  20. data/lib/rubyXL/objects/font.rb +111 -0
  21. data/lib/rubyXL/objects/formula.rb +24 -0
  22. data/lib/rubyXL/objects/ooxml_object.rb +295 -0
  23. data/lib/rubyXL/objects/reference.rb +110 -0
  24. data/lib/rubyXL/objects/relationships.rb +59 -0
  25. data/lib/rubyXL/objects/shared_strings.rb +57 -0
  26. data/lib/rubyXL/objects/sheet_data.rb +149 -0
  27. data/lib/rubyXL/objects/sheet_view.rb +71 -0
  28. data/lib/rubyXL/objects/stylesheet.rb +200 -0
  29. data/lib/rubyXL/objects/text.rb +87 -0
  30. data/lib/rubyXL/objects/theme.rb +64 -0
  31. data/lib/rubyXL/objects/workbook.rb +233 -0
  32. data/lib/rubyXL/objects/worksheet.rb +485 -0
  33. data/lib/rubyXL/parser.rb +78 -442
  34. data/lib/rubyXL/workbook.rb +216 -385
  35. data/lib/rubyXL/worksheet.rb +509 -1062
  36. data/lib/rubyXL/writer/content_types_writer.rb +104 -68
  37. data/lib/rubyXL/writer/core_writer.rb +26 -43
  38. data/lib/rubyXL/writer/generic_writer.rb +43 -0
  39. data/lib/rubyXL/writer/root_rels_writer.rb +11 -19
  40. data/lib/rubyXL/writer/styles_writer.rb +6 -398
  41. data/lib/rubyXL/writer/theme_writer.rb +321 -327
  42. data/lib/rubyXL/writer/workbook_writer.rb +63 -67
  43. data/lib/rubyXL/writer/worksheet_writer.rb +29 -218
  44. data/rdoc/created.rid +39 -0
  45. data/rdoc/fonts.css +167 -0
  46. data/rdoc/fonts/Lato-Light.ttf +0 -0
  47. data/rdoc/fonts/Lato-LightItalic.ttf +0 -0
  48. data/rdoc/fonts/Lato-Regular.ttf +0 -0
  49. data/rdoc/fonts/Lato-RegularItalic.ttf +0 -0
  50. data/rdoc/fonts/SourceCodePro-Bold.ttf +0 -0
  51. data/rdoc/fonts/SourceCodePro-Regular.ttf +0 -0
  52. data/rdoc/images/add.png +0 -0
  53. data/rdoc/images/arrow_up.png +0 -0
  54. data/rdoc/images/brick.png +0 -0
  55. data/rdoc/images/brick_link.png +0 -0
  56. data/rdoc/images/bug.png +0 -0
  57. data/rdoc/images/bullet_black.png +0 -0
  58. data/rdoc/images/bullet_toggle_minus.png +0 -0
  59. data/rdoc/images/bullet_toggle_plus.png +0 -0
  60. data/rdoc/images/date.png +0 -0
  61. data/rdoc/images/delete.png +0 -0
  62. data/rdoc/images/find.png +0 -0
  63. data/rdoc/images/loadingAnimation.gif +0 -0
  64. data/rdoc/images/macFFBgHack.png +0 -0
  65. data/rdoc/images/package.png +0 -0
  66. data/rdoc/images/page_green.png +0 -0
  67. data/rdoc/images/page_white_text.png +0 -0
  68. data/rdoc/images/page_white_width.png +0 -0
  69. data/rdoc/images/plugin.png +0 -0
  70. data/rdoc/images/ruby.png +0 -0
  71. data/rdoc/images/tag_blue.png +0 -0
  72. data/rdoc/images/tag_green.png +0 -0
  73. data/rdoc/images/transparent.png +0 -0
  74. data/rdoc/images/wrench.png +0 -0
  75. data/rdoc/images/wrench_orange.png +0 -0
  76. data/rdoc/images/zoom.png +0 -0
  77. data/rdoc/js/darkfish.js +140 -0
  78. data/rdoc/js/jquery.js +18 -0
  79. data/rdoc/js/navigation.js +142 -0
  80. data/rdoc/js/search.js +109 -0
  81. data/rdoc/js/search_index.js +1 -0
  82. data/rdoc/js/searcher.js +228 -0
  83. data/rdoc/rdoc.css +580 -0
  84. data/rubyXL.gemspec +90 -34
  85. data/spec/lib/cell_spec.rb +29 -59
  86. data/spec/lib/parser_spec.rb +35 -19
  87. data/spec/lib/reference_spec.rb +29 -0
  88. data/spec/lib/stylesheet_spec.rb +29 -0
  89. data/spec/lib/workbook_spec.rb +22 -17
  90. data/spec/lib/worksheet_spec.rb +47 -202
  91. metadata +185 -148
  92. data/lib/.DS_Store +0 -0
  93. data/lib/rubyXL/Hash.rb +0 -60
  94. data/lib/rubyXL/color.rb +0 -14
  95. data/lib/rubyXL/private_class.rb +0 -265
  96. data/lib/rubyXL/writer/app_writer.rb +0 -62
  97. data/lib/rubyXL/writer/calc_chain_writer.rb +0 -33
  98. data/lib/rubyXL/writer/shared_strings_writer.rb +0 -30
  99. data/lib/rubyXL/writer/workbook_rels_writer.rb +0 -59
  100. data/lib/rubyXL/zip.rb +0 -20
  101. data/spec/lib/hash_spec.rb +0 -28
@@ -0,0 +1,485 @@
1
+ require 'rubyXL/objects/ooxml_object'
2
+ require 'rubyXL/objects/extensions'
3
+ require 'rubyXL/objects/text'
4
+ require 'rubyXL/objects/formula'
5
+ require 'rubyXL/objects/sheet_view'
6
+ require 'rubyXL/objects/sheet_data'
7
+ require 'rubyXL/objects/data_validation'
8
+
9
+ module RubyXL
10
+
11
+ # Eventually, the entire code for Worksheet will be moved here. One small step at a time!
12
+
13
+ # http://www.schemacentral.com/sc/ooxml/e-ssml_outlinePr-1.html
14
+ class OutlineProperties < OOXMLObject
15
+ define_attribute(:applyStyles, :bool, :default => false)
16
+ define_attribute(:summaryBelow, :bool, :default => true)
17
+ define_attribute(:summaryRight, :bool, :default => true)
18
+ define_attribute(:showOutlineSymbols, :bool, :default => true)
19
+ define_element_name 'outlinePr'
20
+ end
21
+
22
+ # http://www.schemacentral.com/sc/ooxml/e-ssml_pageSetUpPr-1.html
23
+ class PageSetupProperties < OOXMLObject
24
+ define_attribute(:autoPageBreaks, :bool, :default => true)
25
+ define_attribute(:fitToPage, :bool, :default => false)
26
+ define_element_name 'pageSetUpPr'
27
+ end
28
+
29
+ # http://www.schemacentral.com/sc/ooxml/e-ssml_sheetPr-3.html
30
+ class WorksheetProperties < OOXMLObject
31
+ define_attribute(:syncHorizontal, :bool, :default => false)
32
+ define_attribute(:syncVertical, :bool, :default => false)
33
+ define_attribute(:syncRef, :ref)
34
+ define_attribute(:transitionEvaluation, :bool, :default => false)
35
+ define_attribute(:transitionEntry, :bool, :default => false)
36
+ define_attribute(:published, :bool, :default => true)
37
+ define_attribute(:codeName, :string)
38
+ define_attribute(:filterMode, :bool, :default => false)
39
+ define_attribute(:enableFormatConditionsCalculation, :bool, :default => true)
40
+ define_child_node(RubyXL::Color, :node_name => :tabColor)
41
+ define_child_node(RubyXL::OutlineProperties)
42
+ define_child_node(RubyXL::PageSetupProperties)
43
+ define_element_name 'sheetPr'
44
+ end
45
+
46
+ # http://www.schemacentral.com/sc/ooxml/e-ssml_dimension-3.html
47
+ class WorksheetDimensions < OOXMLObject
48
+ define_attribute(:ref, :ref)
49
+ define_element_name 'dimension'
50
+ end
51
+
52
+ class WorksheetFormatProperties < OOXMLObject
53
+ define_attribute(:baseColWidth, :int, :default => 8)
54
+ define_attribute(:defaultColWidth, :float)
55
+ define_attribute(:defaultRowHeight, :float, :required => true)
56
+ define_attribute(:customHeight, :bool, :default => false)
57
+ define_attribute(:zeroHeight, :bool, :default => false)
58
+ define_attribute(:thickTop, :bool, :default => false)
59
+ define_attribute(:thickBottom, :bool, :default => false)
60
+ define_attribute(:outlineLevelRow, :int, :default => 0)
61
+ define_attribute(:outlineLevelCol, :int, :default => 0)
62
+ define_element_name 'sheetFormatPr'
63
+ end
64
+
65
+ # http://www.schemacentral.com/sc/ooxml/e-ssml_pageMargins-1.html
66
+ class PageMargins < OOXMLObject
67
+ define_attribute(:left, :float, :required => true)
68
+ define_attribute(:right, :float, :required => true)
69
+ define_attribute(:top, :float, :required => true)
70
+ define_attribute(:bottom, :float, :required => true)
71
+ define_attribute(:header, :float, :required => true)
72
+ define_attribute(:footer, :float, :required => true)
73
+ define_element_name 'pageMargins'
74
+ end
75
+
76
+ # http://www.schemacentral.com/sc/ooxml/e-ssml_pageSetup-1.html
77
+ class PageSetup < OOXMLObject
78
+ define_attribute(:paperSize, :int, :default => 1)
79
+ define_attribute(:scale, :int, :default => 100)
80
+ define_attribute(:firstPageNumber, :int, :default => 1)
81
+ define_attribute(:fitToWidth, :int, :default => 1)
82
+ define_attribute(:fitToHeight, :int, :default => 1)
83
+ define_attribute(:pageOrder, :string, :default => 'downThenOver',
84
+ :values => %w{ downThenOver overThenDown })
85
+ define_attribute(:orientation, :string, :default => 'default',
86
+ :values => %w{ default portrait landscape })
87
+ define_attribute(:usePrinterDefaults, :bool, :default => true)
88
+ define_attribute(:blackAndWhite, :bool, :default => false)
89
+ define_attribute(:draft, :bool, :default => false)
90
+ define_attribute(:cellComments, :string, :default => 'none',
91
+ :values => %w{ none asDisplayed atEnd })
92
+ define_attribute(:useFirstPageNumber, :bool, :default => false)
93
+ define_attribute(:errors, :string, :default => 'displayed',
94
+ :values => %w{ displayed blank dash NA })
95
+ define_attribute(:horizontalDpi, :int, :default => 600)
96
+ define_attribute(:verticalDpi, :int, :default => 600)
97
+ define_attribute(:copies, :int, :default => 1)
98
+
99
+ define_attribute(:'r:id', :string)
100
+ define_element_name 'pageSetup'
101
+ end
102
+
103
+ class RID < OOXMLObject
104
+ define_attribute(:'r:id', :string, :required => true)
105
+ end
106
+
107
+ class TableParts < OOXMLObject
108
+ define_child_node(RubyXL::RID, :collection => :with_count, :node_name => :table_part)
109
+ define_element_name 'tableParts'
110
+ end
111
+
112
+ # http://www.schemacentral.com/sc/ooxml/e-ssml_mergeCell-1.html
113
+ class MergedCell < OOXMLObject
114
+ define_attribute(:ref, :ref)
115
+ define_element_name 'mergeCell'
116
+ end
117
+
118
+ # http://www.schemacentral.com/sc/ooxml/e-ssml_mergeCells-1.html
119
+ class MergedCells < OOXMLObject
120
+ define_child_node(RubyXL::MergedCell, :collection => :with_count)
121
+ define_element_name 'mergeCells'
122
+ end
123
+
124
+ # http://www.schemacentral.com/sc/ooxml/e-ssml_printOptions-1.html
125
+ class PrintOptions < OOXMLObject
126
+ define_attribute(:horizontalCentered, :bool, :default => false)
127
+ define_attribute(:verticalCentered, :bool, :default => false)
128
+ define_attribute(:headings, :bool, :default => false)
129
+ define_attribute(:gridLines, :bool, :default => false)
130
+ define_attribute(:gridLinesSet, :bool, :default => true)
131
+ define_element_name 'printOptions'
132
+ end
133
+
134
+ # http://www.schemacentral.com/sc/ooxml/e-ssml_headerFooter-1.html
135
+ class HeaderFooterSettings < OOXMLObject
136
+ define_attribute(:differentOddEven, :bool, :default => false)
137
+ define_attribute(:differentFirst, :bool, :default => false)
138
+ define_attribute(:scaleWithDoc, :bool, :default => true)
139
+ define_attribute(:alignWithMargins, :bool, :default => true)
140
+ define_child_node(RubyXL::StringValue, :node_name => :oddHeader)
141
+ define_child_node(RubyXL::StringValue, :node_name => :oddFooter)
142
+ define_child_node(RubyXL::StringValue, :node_name => :evenHeader)
143
+ define_child_node(RubyXL::StringValue, :node_name => :evenFooter)
144
+ define_child_node(RubyXL::StringValue, :node_name => :firstHeader)
145
+ define_child_node(RubyXL::StringValue, :node_name => :firstFooter)
146
+ define_element_name 'headerFooter'
147
+ end
148
+
149
+ # http://www.schemacentral.com/sc/ooxml/e-ssml_sheetCalcPr-1.html
150
+ class SheetCalculationProperties < OOXMLObject
151
+ define_attribute(:fullCalcOnLoad, :bool, :default => false)
152
+ define_element_name 'sheetCalcPr'
153
+ end
154
+
155
+ # http://www.schemacentral.com/sc/ooxml/e-ssml_protectedRange-1.html
156
+ class ProtectedRange < OOXMLObject
157
+ define_attribute(:password, :string)
158
+ define_attribute(:sqref, :sqref, :required => true)
159
+ define_attribute(:name, :string, :required => true)
160
+ define_attribute(:securityDescriptor, :string)
161
+ define_element_name 'protectedRange'
162
+ end
163
+
164
+ # http://www.schemacentral.com/sc/ooxml/e-ssml_protectedRanges-1.html
165
+ class ProtectedRanges < OOXMLObject
166
+ define_child_node(RubyXL::ProtectedRange, :collection => true)
167
+ define_element_name 'protectedRanges'
168
+ end
169
+
170
+ # http://www.schemacentral.com/sc/ooxml/e-ssml_sheetProtection-1.html
171
+ class SheetProtection < OOXMLObject
172
+ define_attribute(:password, :string)
173
+ define_attribute(:sheet, :bool, :default => false)
174
+ define_attribute(:objects, :bool, :default => false)
175
+ define_attribute(:scenarios, :bool, :default => false)
176
+ define_attribute(:formatCells, :bool, :default => true)
177
+ define_attribute(:formatColumns, :bool, :default => true)
178
+ define_attribute(:formatRows, :bool, :default => true)
179
+ define_attribute(:insertColumns, :bool, :default => true)
180
+ define_attribute(:insertRows, :bool, :default => true)
181
+ define_attribute(:insertHyperlinks, :bool, :default => true)
182
+ define_attribute(:deleteColumns, :bool, :default => true)
183
+ define_attribute(:deleteRows, :bool, :default => true)
184
+ define_attribute(:selectLockedCells, :bool, :default => false)
185
+ define_attribute(:sort, :bool, :default => true)
186
+ define_attribute(:autoFilter, :bool, :default => true)
187
+ define_attribute(:pivotTables, :bool, :default => true)
188
+ define_attribute(:selectUnlockedCells, :bool, :default => false)
189
+ define_element_name 'sheetProtection'
190
+ end
191
+
192
+ # http://www.schemacentral.com/sc/ooxml/e-ssml_cfvo-1.html
193
+ class ConditionalFormatValue < OOXMLObject
194
+ define_attribute(:type, :string, :required => true, :values =>
195
+ %w{ num percent max min formula percentile })
196
+ define_attribute(:val, :string)
197
+ define_attribute(:gte, :bool, :default => true)
198
+ define_child_node(RubyXL::ExtensionStorageArea)
199
+ define_element_name 'cfvo'
200
+ end
201
+
202
+ # http://www.schemacentral.com/sc/ooxml/e-ssml_colorScale-1.html
203
+ class ColorScale < OOXMLObject
204
+ define_child_node(RubyXL::ConditionalFormatValue, :collection => true, :accessor => :cfvo)
205
+ define_child_node(RubyXL::Color)
206
+ define_element_name 'colorScale'
207
+ end
208
+
209
+ # http://www.schemacentral.com/sc/ooxml/e-ssml_dataBar-1.html
210
+ class DataBar < OOXMLObject
211
+ define_attribute(:minLength, :int, :default => 10)
212
+ define_attribute(:maxLength, :int, :default => 90)
213
+ define_attribute(:showValue, :bool, :default => true)
214
+ define_child_node(RubyXL::ConditionalFormatValue, :collection => true, :accessor => :cfvo)
215
+ define_child_node(RubyXL::Color)
216
+ define_element_name 'dataBar'
217
+ end
218
+
219
+ # http://www.schemacentral.com/sc/ooxml/e-ssml_iconSet-1.html
220
+ class IconSet < OOXMLObject
221
+ define_attribute(:type, :string, :required => true, :default => '3TrafficLights1', :values =>
222
+ %w{ 3Arrows 3ArrowsGray 3Flags 3TrafficLights1 3TrafficLights2
223
+ 3Signs 3Symbols 3Symbols2 4Arrows 4ArrowsGray 4RedToBlack
224
+ 4Rating 4TrafficLights 5Arrows 5ArrowsGray 5Rating 5Quarters })
225
+ define_attribute(:showValue, :bool, :default => true)
226
+ define_attribute(:percent, :bool, :default => true)
227
+ define_attribute(:reverse, :bool, :default => false)
228
+ define_child_node(RubyXL::ConditionalFormatValue, :collection => true, :accessor => :cfvo)
229
+ define_element_name 'iconSet'
230
+ end
231
+
232
+ # http://www.schemacentral.com/sc/ooxml/e-ssml_cfRule-1.html
233
+ class ConditionalFormattingRule < OOXMLObject
234
+ define_attribute(:type, :string, :values =>
235
+ %w{ expression cellIs colorScale dataBar iconSet top10 uniqueValues
236
+ duplicateValues containsText notContainsText beginsWith
237
+ endsWith containsBlanks notContainsBlanks containsErrors
238
+ notContainsErrors timePeriod aboveAverage })
239
+ define_attribute(:dxfId, :int)
240
+ define_attribute(:priority, :int, :required => 1)
241
+ define_attribute(:stopIfTrue, :bool, :default => false)
242
+ define_attribute(:aboveAverage, :bool, :default => true)
243
+ define_attribute(:percent, :bool, :default => false)
244
+ define_attribute(:bottom, :bool, :default => false)
245
+ define_attribute(:operator, :string, :values =>
246
+ %w{ lessThan lessThanOrEqual equal notEqual greaterThanOrEqual greaterThan
247
+ between notBetween containsText notContains beginsWith endsWith })
248
+ define_attribute(:text, :string)
249
+ define_attribute(:timePeriod, :string, :values =>
250
+ %w{ today yesterday tomorrow last7Days thisMonth
251
+ lastMonth nextMonth thisWeek lastWeek nextWeek })
252
+ define_attribute(:rank, :int)
253
+ define_attribute(:stdDev, :int)
254
+ define_attribute(:equalAverage, :bool, :default => false)
255
+ define_child_node(RubyXL::Formula, :collection => true, :node_name => :formula, :accessor => :formulas)
256
+ define_child_node(RubyXL::ColorScale)
257
+ define_child_node(RubyXL::DataBar)
258
+ define_child_node(RubyXL::IconSet)
259
+ define_child_node(RubyXL::ExtensionStorageArea)
260
+ define_element_name 'cfRule'
261
+ end
262
+
263
+ # http://www.schemacentral.com/sc/ooxml/e-ssml_brk-1.html
264
+ class Break < OOXMLObject
265
+ define_attribute(:id, :int, :default => 0)
266
+ define_attribute(:min, :int, :default => 0)
267
+ define_attribute(:max, :int, :default => 0)
268
+ define_attribute(:man, :bool, :default => false)
269
+ define_attribute(:pt, :bool, :default => false)
270
+ define_element_name 'brk'
271
+ end
272
+
273
+ # http://www.schemacentral.com/sc/ooxml/e-ssml_rowBreaks-1.html
274
+ class BreakList < OOXMLObject
275
+ define_attribute(:manualBreakCount, :int, :default => 0)
276
+ define_child_node(RubyXL::Break, :collection => :with_count)
277
+ end
278
+
279
+ # http://www.schemacentral.com/sc/ooxml/e-ssml_conditionalFormatting-1.html
280
+ class ConditionalFormatting < OOXMLObject
281
+ define_attribute(:pivot, :bool, :default => false)
282
+ define_attribute(:sqref, :sqref)
283
+ define_child_node(RubyXL::ConditionalFormattingRule, :collection => true, :accessor => :cf_rules)
284
+ define_child_node(RubyXL::ExtensionStorageArea)
285
+ define_element_name 'conditionalFormatting'
286
+ end
287
+
288
+ # http://www.schemacentral.com/sc/ooxml/e-ssml_inputCells-1.html
289
+ class InputCells < OOXMLObject
290
+ define_attribute(:r, :ref, :required => true)
291
+ define_attribute(:deleted, :bool, :default => false)
292
+ define_attribute(:undone, :bool, :default => false)
293
+ define_attribute(:val, :string, :required => true)
294
+ define_attribute(:numFmtId, :int)
295
+ define_element_name 'inputCells'
296
+ end
297
+
298
+ # http://www.schemacentral.com/sc/ooxml/e-ssml_scenario-1.html
299
+ class Scenario < OOXMLObject
300
+ define_attribute(:name, :string)
301
+ define_attribute(:locked, :bool, :default => false)
302
+ define_attribute(:hidden, :bool, :default => false)
303
+ define_attribute(:user, :string)
304
+ define_attribute(:comment, :string)
305
+ define_child_node(RubyXL::InputCells, :collection => :with_count)
306
+ define_element_name 'scenario'
307
+ end
308
+
309
+ # http://www.schemacentral.com/sc/ooxml/e-ssml_scenarios-1.html
310
+ class ScenarioContainer < OOXMLObject
311
+ define_attribute(:current, :int)
312
+ define_attribute(:show, :int)
313
+ define_attribute(:sqref, :sqref)
314
+ define_child_node(RubyXL::Scenario, :collection => true, :accessor => :scenarios)
315
+ define_element_name 'scenarios'
316
+ end
317
+
318
+ # http://www.schemacentral.com/sc/ooxml/e-ssml_ignoredError-1.html
319
+ class IgnoredError < OOXMLObject
320
+ define_attribute(:sqref, :sqref, :required => true)
321
+ define_attribute(:pivot, :bool, :default => false)
322
+ define_attribute(:evalError, :bool, :default => false)
323
+ define_attribute(:twoDigitTextYear, :bool, :default => false)
324
+ define_attribute(:numberStoredAsText, :bool, :default => false)
325
+ define_attribute(:formula, :bool, :default => false)
326
+ define_attribute(:formulaRange, :bool, :default => false)
327
+ define_attribute(:unlockedFormula, :bool, :default => false)
328
+ define_attribute(:emptyCellReference, :bool, :default => false)
329
+ define_attribute(:listDataValidation, :bool, :default => false)
330
+ define_attribute(:calculatedColumn, :bool, :default => false)
331
+ define_element_name 'ignoredError'
332
+ end
333
+
334
+ # http://www.schemacentral.com/sc/ooxml/e-ssml_ignoredErrors-1.html
335
+ class IgnoredErrorContainer < OOXMLObject
336
+ define_child_node(RubyXL::IgnoredError, :collection => true, :accessor => :scenarios)
337
+ define_child_node(RubyXL::ExtensionStorageArea)
338
+ define_element_name 'ignoredErrors'
339
+ end
340
+
341
+ # http://www.schemacentral.com/sc/ooxml/e-ssml_sortCondition-1.html
342
+ class SortCondition < OOXMLObject
343
+ define_attribute(:descending, :bool, :default => false)
344
+ define_attribute(:sortBy, :string, :default => 'value',
345
+ :values => %w{ value cellColor fontColor icon })
346
+ define_attribute(:ref, :ref, :required => true)
347
+ define_attribute(:customList, :string)
348
+ define_attribute(:dxfId, :int)
349
+ define_attribute(:iconSet, :string, :required => true, :default => '3Arrows', :values =>
350
+ %w{ 3Arrows 3ArrowsGray 3Flags 3TrafficLights1 3TrafficLights2
351
+ 3Signs 3Symbols 3Symbols2 4Arrows 4ArrowsGray 4RedToBlack
352
+ 4Rating 4TrafficLights 5Arrows 5ArrowsGray 5Rating 5Quarters })
353
+ define_attribute(:iconId, :int)
354
+ define_element_name 'sortCondition'
355
+ end
356
+
357
+ # http://www.schemacentral.com/sc/ooxml/e-ssml_sortState-2.html
358
+ class SortState < OOXMLObject
359
+ define_attribute(:columnSort, :bool, :default => false)
360
+ define_attribute(:caseSensitive, :bool, :default => false)
361
+ define_attribute(:sortMethod, :string, :default => 'none',
362
+ :values => %w{ stroke pinYin none })
363
+ define_attribute(:ref, :ref, :required => true)
364
+ define_child_node(RubyXL::SortCondition, :colection => true)
365
+ define_child_node(RubyXL::ExtensionStorageArea)
366
+ define_element_name 'sortState'
367
+ end
368
+
369
+ # http://www.schemacentral.com/sc/ooxml/e-ssml_hyperlink-1.html
370
+ class Hyperlink < OOXMLObject
371
+ define_attribute(:ref, :ref, :required => true)
372
+ define_attribute(:'r:id', :string)
373
+ define_attribute(:location, :string)
374
+ define_attribute(:tooltip, :string)
375
+ define_attribute(:display, :string)
376
+ define_element_name 'hyperlink'
377
+ end
378
+
379
+ # http://www.schemacentral.com/sc/ooxml/e-ssml_hyperlinks-1.html
380
+ class HyperlinkContainer < OOXMLObject
381
+ define_child_node(RubyXL::Hyperlink, :colection => true, :accessor => :hyperlinks)
382
+ define_element_name 'hyperlinks'
383
+ end
384
+
385
+ # http://www.schemacentral.com/sc/ooxml/s-sml-sheet.xsd.html
386
+ class Worksheet < OOXMLObject
387
+ define_child_node(RubyXL::WorksheetProperties)
388
+ define_child_node(RubyXL::WorksheetDimensions)
389
+ define_child_node(RubyXL::SheetViews)
390
+ define_child_node(RubyXL::WorksheetFormatProperties)
391
+ define_child_node(RubyXL::ColumnRanges)
392
+ define_child_node(RubyXL::SheetData)
393
+ define_child_node(RubyXL::SheetCalculationProperties)
394
+ define_child_node(RubyXL::SheetProtection)
395
+ define_child_node(RubyXL::ProtectedRanges)
396
+ define_child_node(RubyXL::ScenarioContainer)
397
+ # ssml:autoFilter [0..1] AutoFilter
398
+ define_child_node(RubyXL::SortState)
399
+ # ssml:dataConsolidate [0..1] Data Consolidate
400
+ # ssml:customSheetViews [0..1] Custom Sheet Views
401
+ define_child_node(RubyXL::MergedCells, :accessor => :merged_cells_list)
402
+ define_child_node(RubyXL::PhoneticProperties)
403
+ define_child_node(RubyXL::ConditionalFormatting)
404
+ define_child_node(RubyXL::DataValidations)
405
+ define_child_node(RubyXL::HyperlinkContainer)
406
+ define_child_node(RubyXL::PrintOptions)
407
+ define_child_node(RubyXL::PageMargins)
408
+ define_child_node(RubyXL::PageSetup)
409
+ define_child_node(RubyXL::HeaderFooterSettings)
410
+ define_child_node(RubyXL::BreakList, :node_name => :rowBreaks)
411
+ define_child_node(RubyXL::BreakList, :node_name => :colBreaks)
412
+ # ssml:customProperties [0..1] Custom Properties
413
+ # ssml:cellWatches [0..1] Cell Watch Items
414
+ define_child_node(RubyXL::IgnoredErrorContainer)
415
+ # ssml:smartTags [0..1] Smart Tags
416
+ define_child_node(RubyXL::RID, :node_name => :drawing)
417
+ define_child_node(RubyXL::RID, :node_name => :legacyDrawing)
418
+ define_child_node(RubyXL::RID, :node_name => :legacyDrawingHF)
419
+ define_child_node(RubyXL::RID, :node_name => :picture)
420
+ # ssml:oleObjects [0..1] OLE Objects
421
+ # ssml:controls [0..1] Embedded Controls
422
+ # ssml:webPublishItems [0..1] Web Publishing Items
423
+ define_child_node(RubyXL::TableParts)
424
+ define_child_node(RubyXL::ExtensionStorageArea)
425
+ define_element_name 'worksheet'
426
+ set_namespaces('xmlns' => 'http://schemas.openxmlformats.org/spreadsheetml/2006/main',
427
+ 'xmlns:r' => 'http://schemas.openxmlformats.org/officeDocument/2006/relationships',
428
+ 'xmlns:mc' => 'http://schemas.openxmlformats.org/markup-compatibility/2006',
429
+ 'xmlns:x14ac' => 'http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac',
430
+ 'xmlns:mv' => 'urn:schemas-microsoft-com:mac:vml')
431
+
432
+ def before_write_xml # This method may need to be moved higher in the hierarchy
433
+ first_nonempty_row = nil
434
+ last_nonempty_row = 0
435
+ first_nonempty_column = nil
436
+ last_nonempty_column = 0
437
+
438
+ if sheet_data then
439
+ sheet_data.rows.each_with_index { |row, row_index|
440
+ next if row.nil? || row.cells.empty?
441
+
442
+ first_nonempty_cell = nil
443
+ last_nonempty_cell = 0
444
+
445
+ row.cells.each_with_index { |cell, col_index|
446
+ next if cell.nil?
447
+ cell.r = RubyXL::Reference.new(row_index, col_index)
448
+
449
+ first_nonempty_cell ||= col_index
450
+ last_nonempty_cell = col_index
451
+ }
452
+
453
+ if first_nonempty_cell then # If there's nothing in this row, then +first_nonempty_cell+ will be +nil+.
454
+ last_nonempty_row = row_index
455
+ first_nonempty_row ||= row_index
456
+
457
+ first_nonempty_column ||= first_nonempty_cell
458
+ last_nonempty_column = last_nonempty_cell if last_nonempty_cell > last_nonempty_column
459
+ end
460
+
461
+ row.r = row_index + 1
462
+ row.spans = "#{first_nonempty_cell + 1}:#{last_nonempty_cell + 1}"
463
+ row.custom_format = (row.s.to_i != 0)
464
+ }
465
+
466
+ if first_nonempty_row then
467
+ self.dimension ||= RubyXL::WorksheetDimensions.new
468
+ self.dimension.ref = RubyXL::Reference.new(first_nonempty_row, last_nonempty_row,
469
+ first_nonempty_column, last_nonempty_column)
470
+ end
471
+
472
+ end
473
+
474
+ true
475
+ end
476
+
477
+ def merged_cells
478
+ (merged_cells_list && merged_cells_list.merge_cell) || []
479
+ end
480
+
481
+ include LegacyWorksheet
482
+
483
+ end
484
+
485
+ end