axlsx 1.0.8 → 1.0.9
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.
- data/CHANGELOG.md +14 -0
- data/README.md +22 -21
- data/Rakefile +1 -1
- data/axlsx.gemspec +36 -0
- data/doc/Axlsx.html +373 -559
- data/doc/Axlsx/App.html +257 -360
- data/doc/Axlsx/Axis.html +113 -144
- data/doc/Axlsx/Bar3DChart.html +122 -152
- data/doc/Axlsx/BarSeries.html +67 -81
- data/doc/Axlsx/Border.html +96 -119
- data/doc/Axlsx/BorderPr.html +89 -114
- data/doc/Axlsx/CatAxis.html +79 -104
- data/doc/Axlsx/CatAxisData.html +40 -54
- data/doc/Axlsx/Cell.html +193 -679
- data/doc/Axlsx/CellAlignment.html +116 -157
- data/doc/Axlsx/CellProtection.html +50 -68
- data/doc/Axlsx/CellStyle.html +78 -106
- data/doc/Axlsx/Chart.html +361 -432
- data/doc/Axlsx/Color.html +56 -78
- data/doc/Axlsx/ContentType.html +28 -41
- data/doc/Axlsx/Core.html +43 -55
- data/doc/Axlsx/DataTypeValidator.html +34 -43
- data/doc/Axlsx/Default.html +55 -81
- data/doc/Axlsx/Drawing.html +322 -412
- data/doc/Axlsx/Fill.html +34 -47
- data/doc/Axlsx/Font.html +157 -207
- data/doc/Axlsx/GradientFill.html +90 -122
- data/doc/Axlsx/GradientStop.html +36 -50
- data/doc/Axlsx/GraphicFrame.html +106 -130
- data/doc/Axlsx/Line3DChart.html +108 -134
- data/doc/Axlsx/LineSeries.html +58 -67
- data/doc/Axlsx/Marker.html +84 -111
- data/doc/Axlsx/NumFmt.html +83 -102
- data/doc/Axlsx/OneCellAnchor.html +158 -196
- data/doc/Axlsx/Override.html +60 -92
- data/doc/Axlsx/Package.html +190 -759
- data/doc/Axlsx/PatternFill.html +78 -99
- data/doc/Axlsx/Pic.html +451 -405
- data/doc/Axlsx/Pie3DChart.html +33 -42
- data/doc/Axlsx/PieSeries.html +68 -80
- data/doc/Axlsx/RegexValidator.html +15 -20
- data/doc/Axlsx/Relationship.html +49 -66
- data/doc/Axlsx/Relationships.html +28 -41
- data/doc/Axlsx/RestrictionValidator.html +23 -32
- data/doc/Axlsx/Row.html +132 -161
- data/doc/Axlsx/Scaling.html +71 -90
- data/doc/Axlsx/SerAxis.html +61 -79
- data/doc/Axlsx/Series.html +125 -201
- data/doc/Axlsx/SeriesTitle.html +26 -31
- data/doc/Axlsx/Styles.html +286 -355
- data/doc/Axlsx/TableStyle.html +62 -87
- data/doc/Axlsx/TableStyleElement.html +84 -104
- data/doc/Axlsx/TableStyles.html +59 -82
- data/doc/Axlsx/Title.html +58 -155
- data/doc/Axlsx/TwoCellAnchor.html +165 -204
- data/doc/Axlsx/ValAxis.html +39 -53
- data/doc/Axlsx/ValAxisData.html +29 -39
- data/doc/Axlsx/View3D.html +93 -122
- data/doc/Axlsx/Workbook.html +359 -362
- data/doc/Axlsx/Worksheet.html +471 -816
- data/doc/Axlsx/Xf.html +341 -296
- data/doc/_index.html +7 -11
- data/doc/class_list.html +1 -1
- data/doc/file.LICENSE.html +86 -0
- data/doc/file.README.html +105 -107
- data/doc/file_list.html +3 -0
- data/doc/frames.html +1 -1
- data/doc/index.html +105 -107
- data/doc/method_list.html +426 -602
- data/doc/top-level-namespace.html +3 -3
- data/examples/example.rb +20 -1
- data/lib/axlsx.rb +20 -15
- data/lib/axlsx/content_type/default.rb +8 -3
- data/lib/axlsx/content_type/override.rb +11 -4
- data/lib/axlsx/doc_props/app.rb +53 -23
- data/lib/axlsx/drawing/axis.rb +16 -5
- data/lib/axlsx/drawing/bar_3D_chart.rb +15 -7
- data/lib/axlsx/drawing/bar_series.rb +7 -5
- data/lib/axlsx/drawing/cat_axis.rb +10 -3
- data/lib/axlsx/drawing/chart.rb +21 -15
- data/lib/axlsx/drawing/drawing.rb +16 -30
- data/lib/axlsx/drawing/graphic_frame.rb +2 -4
- data/lib/axlsx/drawing/line_3D_chart.rb +5 -2
- data/lib/axlsx/drawing/line_series.rb +6 -5
- data/lib/axlsx/drawing/marker.rb +9 -5
- data/lib/axlsx/drawing/one_cell_anchor.rb +7 -7
- data/lib/axlsx/drawing/pic.rb +29 -37
- data/lib/axlsx/drawing/pie_series.rb +7 -5
- data/lib/axlsx/drawing/scaling.rb +11 -5
- data/lib/axlsx/drawing/ser_axis.rb +6 -2
- data/lib/axlsx/drawing/series.rb +11 -11
- data/lib/axlsx/drawing/series_title.rb +1 -1
- data/lib/axlsx/drawing/title.rb +5 -12
- data/lib/axlsx/drawing/two_cell_anchor.rb +2 -3
- data/lib/axlsx/drawing/val_axis.rb +2 -2
- data/lib/axlsx/drawing/view_3D.rb +16 -9
- data/lib/axlsx/package.rb +25 -27
- data/lib/axlsx/rels/relationship.rb +4 -2
- data/lib/axlsx/stylesheet/border.rb +9 -4
- data/lib/axlsx/stylesheet/border_pr.rb +7 -4
- data/lib/axlsx/stylesheet/cell_alignment.rb +18 -9
- data/lib/axlsx/stylesheet/cell_protection.rb +5 -2
- data/lib/axlsx/stylesheet/cell_style.rb +12 -7
- data/lib/axlsx/stylesheet/color.rb +8 -6
- data/lib/axlsx/stylesheet/fill.rb +2 -1
- data/lib/axlsx/stylesheet/font.rb +24 -13
- data/lib/axlsx/stylesheet/gradient_fill.rb +16 -10
- data/lib/axlsx/stylesheet/gradient_stop.rb +5 -3
- data/lib/axlsx/stylesheet/num_fmt.rb +4 -2
- data/lib/axlsx/stylesheet/pattern_fill.rb +6 -4
- data/lib/axlsx/stylesheet/styles.rb +12 -12
- data/lib/axlsx/stylesheet/table_style.rb +6 -3
- data/lib/axlsx/stylesheet/table_style_element.rb +9 -4
- data/lib/axlsx/stylesheet/table_styles.rb +4 -4
- data/lib/axlsx/stylesheet/xf.rb +52 -31
- data/lib/axlsx/util/validators.rb +3 -3
- data/lib/axlsx/version.rb +1 -1
- data/lib/axlsx/workbook/workbook.rb +8 -9
- data/lib/axlsx/workbook/worksheet/cell.rb +25 -16
- data/lib/axlsx/workbook/worksheet/row.rb +2 -4
- data/lib/axlsx/workbook/worksheet/worksheet.rb +23 -32
- data/test/drawing/tc_one_cell_anchor.rb +1 -1
- metadata +135 -165
- data/doc/Axlsx/SimpleTypedList.html +0 -1686
- data/lib/schema/dc.xsd~ +0 -118
- data/lib/schema/dcterms.xsd~ +0 -331
- data/lib/schema/opc-coreProperties.xsd~ +0 -50
- data/test/drawing/tc_line_series.tc~ +0 -34
|
@@ -37,11 +37,11 @@ module Axlsx
|
|
|
37
37
|
# 48 ##0.0E+0
|
|
38
38
|
# 49 @
|
|
39
39
|
# @see Axlsx
|
|
40
|
-
|
|
40
|
+
attr_reader :numFmtId
|
|
41
41
|
|
|
42
42
|
# @return [String] The formatting to use for this number format.
|
|
43
43
|
# @see http://support.microsoft.com/kb/264372
|
|
44
|
-
|
|
44
|
+
attr_reader :formatCode
|
|
45
45
|
def initialize(options={})
|
|
46
46
|
@numFmtId = 0
|
|
47
47
|
@formatCode = ""
|
|
@@ -50,7 +50,9 @@ module Axlsx
|
|
|
50
50
|
end
|
|
51
51
|
end
|
|
52
52
|
|
|
53
|
+
# @see numFmtId
|
|
53
54
|
def numFmtId=(v) Axlsx::validate_unsigned_int v; @numFmtId = v end
|
|
55
|
+
# @see formatCode
|
|
54
56
|
def formatCode=(v) Axlsx::validate_string v; @formatCode = v end
|
|
55
57
|
|
|
56
58
|
# Creates a numFmt element applying the instance values of this object as attributes.
|
|
@@ -6,11 +6,11 @@ module Axlsx
|
|
|
6
6
|
|
|
7
7
|
# The color to use for the the background in solid fills.
|
|
8
8
|
# @return [Color]
|
|
9
|
-
|
|
9
|
+
attr_reader :fgColor
|
|
10
10
|
|
|
11
11
|
# The color to use for the background of the fill when the type is not solid.
|
|
12
12
|
# @return [Color]
|
|
13
|
-
|
|
13
|
+
attr_reader :bgColor
|
|
14
14
|
|
|
15
15
|
# The pattern type to use
|
|
16
16
|
# @note
|
|
@@ -35,7 +35,7 @@ module Axlsx
|
|
|
35
35
|
# :gray125
|
|
36
36
|
# :gray0625
|
|
37
37
|
# @see Office Open XML Part 1 18.18.55
|
|
38
|
-
|
|
38
|
+
attr_reader :patternType
|
|
39
39
|
|
|
40
40
|
# Creates a new PatternFill Object
|
|
41
41
|
# @option options [Symbol] patternType
|
|
@@ -47,9 +47,11 @@ module Axlsx
|
|
|
47
47
|
self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
|
|
48
48
|
end
|
|
49
49
|
end
|
|
50
|
-
|
|
50
|
+
# @see fgColor
|
|
51
51
|
def fgColor=(v) DataTypeValidator.validate "PatternFill.fgColor", Color, v; @fgColor=v end
|
|
52
|
+
# @see bgColor
|
|
52
53
|
def bgColor=(v) DataTypeValidator.validate "PatternFill.bgColor", Color, v; @bgColor=v end
|
|
54
|
+
# @see patternType
|
|
53
55
|
def patternType=(v) Axlsx::validate_pattern_type v; @patternType = v end
|
|
54
56
|
|
|
55
57
|
# Serializes the pattern fill
|
|
@@ -197,10 +197,10 @@ module Axlsx
|
|
|
197
197
|
else
|
|
198
198
|
options[:num_fmt] || 0
|
|
199
199
|
end
|
|
200
|
-
|
|
200
|
+
|
|
201
201
|
borderId = options[:border] || 0
|
|
202
202
|
raise ArgumentError, "Invalid borderId" unless borderId < borders.size
|
|
203
|
-
|
|
203
|
+
|
|
204
204
|
fill = if options[:bg_color]
|
|
205
205
|
color = Color.new(:rgb=>options[:bg_color])
|
|
206
206
|
pattern = PatternFill.new(:patternType =>:solid, :fgColor=>color)
|
|
@@ -208,7 +208,7 @@ module Axlsx
|
|
|
208
208
|
else
|
|
209
209
|
0
|
|
210
210
|
end
|
|
211
|
-
|
|
211
|
+
|
|
212
212
|
fontId = if (options.values_at(:fg_color, :sz, :b, :i, :strike, :outline, :shadow, :charset, :family, :font_name).length)
|
|
213
213
|
font = Font.new()
|
|
214
214
|
[:b, :i, :strike, :outline, :shadow, :charset, :family, :sz].each { |k| font.send("#{k}=", options[k]) unless options[k].nil? }
|
|
@@ -218,11 +218,11 @@ module Axlsx
|
|
|
218
218
|
else
|
|
219
219
|
0
|
|
220
220
|
end
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
221
|
+
|
|
222
|
+
applyProtection = (options[:hidden] || options[:locked]) ? 1 : 0
|
|
223
|
+
|
|
224
224
|
xf = Xf.new(:fillId => fill, :fontId=>fontId, :applyFill=>1, :applyFont=>1, :numFmtId=>numFmtId, :borderId=>borderId, :applyProtection=>applyProtection)
|
|
225
|
-
|
|
225
|
+
|
|
226
226
|
if options[:alignment]
|
|
227
227
|
xf.alignment = CellAlignment.new(options[:alignment])
|
|
228
228
|
end
|
|
@@ -230,16 +230,16 @@ module Axlsx
|
|
|
230
230
|
if applyProtection
|
|
231
231
|
xf.protection = CellProtection.new(options)
|
|
232
232
|
end
|
|
233
|
-
|
|
233
|
+
|
|
234
234
|
cellXfs << xf
|
|
235
|
-
|
|
236
|
-
|
|
235
|
+
end
|
|
236
|
+
|
|
237
237
|
# Serializes the styles document
|
|
238
238
|
# @return [String]
|
|
239
239
|
def to_xml()
|
|
240
240
|
builder = Nokogiri::XML::Builder.new(:encoding => ENCODING) do |xml|
|
|
241
241
|
xml.styleSheet(:xmlns => XML_NS) {
|
|
242
|
-
[:numFmts, :fonts, :fills, :borders, :cellStyleXfs, :cellXfs, :dxfs, :tableStyles].each do |key|
|
|
242
|
+
[:numFmts, :fonts, :fills, :borders, :cellStyleXfs, :cellXfs, :cellStyles, :dxfs, :tableStyles].each do |key|
|
|
243
243
|
self.instance_values[key.to_s].to_xml(xml)
|
|
244
244
|
end
|
|
245
245
|
}
|
|
@@ -280,7 +280,7 @@ module Axlsx
|
|
|
280
280
|
@cellStyleXfs.lock
|
|
281
281
|
|
|
282
282
|
@cellStyles = SimpleTypedList.new CellStyle
|
|
283
|
-
@cellStyles << CellStyle.new(:name =>"
|
|
283
|
+
@cellStyles << CellStyle.new(:name =>"Normal", :builtinId =>0, :xfId=>0)
|
|
284
284
|
@cellStyles.lock
|
|
285
285
|
|
|
286
286
|
@cellXfs = SimpleTypedList.new Xf, "cellXfs"
|
|
@@ -5,15 +5,15 @@ module Axlsx
|
|
|
5
5
|
|
|
6
6
|
# The name of this table style
|
|
7
7
|
# @return [string]
|
|
8
|
-
|
|
8
|
+
attr_reader :name
|
|
9
9
|
|
|
10
10
|
# indicates if this style should be applied to pivot tables
|
|
11
11
|
# @return [Boolean]
|
|
12
|
-
|
|
12
|
+
attr_reader :pivot
|
|
13
13
|
|
|
14
14
|
# indicates if this style should be applied to tables
|
|
15
15
|
# @return [Boolean]
|
|
16
|
-
|
|
16
|
+
attr_reader :table
|
|
17
17
|
|
|
18
18
|
# creates a new TableStyle object
|
|
19
19
|
# @raise [ArgumentError] if name option is not provided.
|
|
@@ -28,8 +28,11 @@ module Axlsx
|
|
|
28
28
|
super TableStyleElement
|
|
29
29
|
end
|
|
30
30
|
|
|
31
|
+
# @see name
|
|
31
32
|
def name=(v) Axlsx::validate_string v; @name=v end
|
|
33
|
+
# @see pivot
|
|
32
34
|
def pivot=(v) Axlsx::validate_boolean v; @pivot=v end
|
|
35
|
+
# @see table
|
|
33
36
|
def table=(v) Axlsx::validate_boolean v; @table=v end
|
|
34
37
|
|
|
35
38
|
# Serializes the table style
|
|
@@ -32,15 +32,15 @@ module Axlsx
|
|
|
32
32
|
# :pageFieldLabels
|
|
33
33
|
# :pageFieldValues
|
|
34
34
|
# @return [Symbol]
|
|
35
|
-
|
|
35
|
+
attr_reader :type
|
|
36
36
|
|
|
37
37
|
# Number of rows or columns used in striping when the type is firstRowStripe, secondRowStripe, firstColumnStripe, or secondColumnStripe.
|
|
38
38
|
# @return [Integer]
|
|
39
|
-
|
|
39
|
+
attr_reader :size
|
|
40
40
|
|
|
41
41
|
# The dxfId this style element points to
|
|
42
42
|
# @return [Integer]
|
|
43
|
-
|
|
43
|
+
attr_reader :dxfId
|
|
44
44
|
|
|
45
45
|
# creates a new TableStyleElement object
|
|
46
46
|
# @option options [Symbol] type
|
|
@@ -51,9 +51,14 @@ module Axlsx
|
|
|
51
51
|
self.send("#{o[0]}=", o[1]) if self.respond_to? o[0]
|
|
52
52
|
end
|
|
53
53
|
end
|
|
54
|
-
|
|
54
|
+
|
|
55
|
+
# @see type
|
|
55
56
|
def type=(v) Axlsx::validate_table_element_type v; @type = v end
|
|
57
|
+
|
|
58
|
+
# @see size
|
|
56
59
|
def size=(v) Axlsx::validate_unsigned_int v; @size = v end
|
|
60
|
+
|
|
61
|
+
# @see dxfId
|
|
57
62
|
def dxfId=(v) Axlsx::validate_unsigned_int v; @dxfId = v end
|
|
58
63
|
|
|
59
64
|
# Serializes the table style element
|
|
@@ -5,12 +5,11 @@ module Axlsx
|
|
|
5
5
|
|
|
6
6
|
# The default table style. The default value is 'TableStyleMedium9'
|
|
7
7
|
# @return [String]
|
|
8
|
-
|
|
9
|
-
attr_accessor :defaultTableStyle
|
|
8
|
+
attr_reader :defaultTableStyle
|
|
10
9
|
|
|
11
10
|
# The default pivot table style. The default value is 'PivotStyleLight6'
|
|
12
11
|
# @return [String]
|
|
13
|
-
|
|
12
|
+
attr_reader :defaultPivotStyle
|
|
14
13
|
|
|
15
14
|
# Creates a new TableStyles object that is a container for TableStyle objects
|
|
16
15
|
# @option options [String] defaultTableStyle
|
|
@@ -20,8 +19,9 @@ module Axlsx
|
|
|
20
19
|
@defaultPivotStyle = options[:defaultPivotStyle] || "PivotStyleLight16"
|
|
21
20
|
super TableStyle
|
|
22
21
|
end
|
|
23
|
-
|
|
22
|
+
# @see defaultTableStyle
|
|
24
23
|
def defaultTableStyle=(v) Axlsx::validate_string(v); @defaultTableStyle = v; end
|
|
24
|
+
# @see defaultPivotStyle
|
|
25
25
|
def defaultPivotStyle=(v) Axlsx::validate_string(v); @defaultPivotStyle = v; end
|
|
26
26
|
|
|
27
27
|
# Serializes the table styles element
|
data/lib/axlsx/stylesheet/xf.rb
CHANGED
|
@@ -1,107 +1,128 @@
|
|
|
1
1
|
module Axlsx
|
|
2
|
-
# The Xf class defines a formatting record for use in Styles
|
|
2
|
+
# The Xf class defines a formatting record for use in Styles. The recommended way to manage styles for your workbook is with Styles#add_style
|
|
3
|
+
# @see Styles#add_style
|
|
3
4
|
class Xf
|
|
4
5
|
#does not support extList (ExtensionList)
|
|
5
6
|
|
|
6
7
|
# The cell alignment for this style
|
|
7
8
|
# @return [CellAlignment]
|
|
8
9
|
# @see CellAlignment
|
|
9
|
-
|
|
10
|
+
attr_reader :alignment
|
|
10
11
|
|
|
11
12
|
# The cell protection for this style
|
|
12
13
|
# @return [CellProtection]
|
|
13
14
|
# @see CellProtection
|
|
14
|
-
|
|
15
|
+
attr_reader :protection
|
|
15
16
|
|
|
16
17
|
# id of the numFmt to apply to this style
|
|
17
18
|
# @return [Integer]
|
|
18
|
-
|
|
19
|
+
attr_reader :numFmtId
|
|
19
20
|
|
|
20
21
|
# index (0 based) of the font to be used in this style
|
|
21
22
|
# @return [Integer]
|
|
22
|
-
|
|
23
|
+
attr_reader :fontId
|
|
23
24
|
|
|
24
25
|
# index (0 based) of the fill to be used in this style
|
|
25
26
|
# @return [Integer]
|
|
26
|
-
|
|
27
|
+
attr_reader :fillId
|
|
27
28
|
|
|
28
29
|
# index (0 based) of the border to be used in this style
|
|
29
30
|
# @return [Integer]
|
|
30
|
-
|
|
31
|
+
attr_reader :borderId
|
|
31
32
|
|
|
32
33
|
# index (0 based) of cellStylesXfs item to be used in this style. Only applies to cellXfs items
|
|
33
34
|
# @return [Integer]
|
|
34
|
-
|
|
35
|
+
attr_reader :xfId
|
|
35
36
|
|
|
36
37
|
# indecates if text should be prefixed by a single quote in the cell
|
|
37
38
|
# @return [Boolean]
|
|
38
|
-
|
|
39
|
+
attr_reader :quotePrefix
|
|
39
40
|
|
|
40
41
|
# indicates if the cell has a pivot table drop down button
|
|
41
42
|
# @return [Boolean]
|
|
42
|
-
|
|
43
|
+
attr_reader :pivotButton
|
|
43
44
|
|
|
44
45
|
# indicates if the numFmtId should be applied
|
|
45
46
|
# @return [Boolean]
|
|
46
|
-
|
|
47
|
+
attr_reader :applyNumberFormat
|
|
47
48
|
|
|
48
49
|
# indicates if the fontId should be applied
|
|
49
50
|
# @return [Boolean]
|
|
50
|
-
|
|
51
|
+
attr_reader :applyFont
|
|
51
52
|
|
|
52
53
|
# indicates if the fillId should be applied
|
|
53
54
|
# @return [Boolean]
|
|
54
|
-
|
|
55
|
+
attr_reader :applyFill
|
|
55
56
|
|
|
56
57
|
# indicates if the borderId should be applied
|
|
57
58
|
# @return [Boolean]
|
|
58
|
-
|
|
59
|
+
attr_reader :applyBorder
|
|
59
60
|
|
|
60
61
|
# Indicates if the alignment options should be applied
|
|
61
62
|
# @return [Boolean]
|
|
62
|
-
|
|
63
|
+
attr_reader :applyAlignment
|
|
63
64
|
|
|
64
65
|
# Indicates if the protection options should be applied
|
|
65
66
|
# @return [Boolean]
|
|
66
|
-
|
|
67
|
+
attr_reader :applyProtection
|
|
67
68
|
|
|
68
69
|
# Creates a new Xf object
|
|
69
|
-
# @option [Integer] numFmtId
|
|
70
|
-
# @option [Integer] fontId
|
|
71
|
-
# @option [Integer] fillId
|
|
72
|
-
# @option [Integer] borderId
|
|
73
|
-
# @option [Integer] xfId
|
|
74
|
-
# @option [Boolean] quotePrefix
|
|
75
|
-
# @option [Boolean] pivotButton
|
|
76
|
-
# @option [Boolean] applyNumberFormat
|
|
77
|
-
# @option [Boolean] applyFont
|
|
78
|
-
# @option [Boolean] applyFill
|
|
79
|
-
# @option [Boolean] applyBorder
|
|
80
|
-
# @option [Boolean] applyAlignment
|
|
81
|
-
# @option [Boolean] applyProtection
|
|
82
|
-
# @option [CellAlignment] alignment
|
|
83
|
-
# @option [CellProtection] protection
|
|
70
|
+
# @option options [Integer] numFmtId
|
|
71
|
+
# @option options [Integer] fontId
|
|
72
|
+
# @option options [Integer] fillId
|
|
73
|
+
# @option options [Integer] borderId
|
|
74
|
+
# @option options [Integer] xfId
|
|
75
|
+
# @option options [Boolean] quotePrefix
|
|
76
|
+
# @option options [Boolean] pivotButton
|
|
77
|
+
# @option options [Boolean] applyNumberFormat
|
|
78
|
+
# @option options [Boolean] applyFont
|
|
79
|
+
# @option options [Boolean] applyFill
|
|
80
|
+
# @option options [Boolean] applyBorder
|
|
81
|
+
# @option options [Boolean] applyAlignment
|
|
82
|
+
# @option options [Boolean] applyProtection
|
|
83
|
+
# @option options [CellAlignment] alignment
|
|
84
|
+
# @option options [CellProtection] protection
|
|
84
85
|
def initialize(options={})
|
|
85
86
|
options.each do |o|
|
|
86
87
|
self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
|
|
87
88
|
end
|
|
88
89
|
end
|
|
89
90
|
|
|
91
|
+
# @see Xf#alignment
|
|
90
92
|
def alignment=(v) DataTypeValidator.validate "Xf.alignment", CellAlignment, v; @alignment = v end
|
|
93
|
+
|
|
94
|
+
# @see protection
|
|
91
95
|
def protection=(v) DataTypeValidator.validate "Xf.protection", CellProtection, v; @protection = v end
|
|
92
96
|
|
|
97
|
+
# @see numFmtId
|
|
93
98
|
def numFmtId=(v) Axlsx::validate_unsigned_int v; @numFmtId = v end
|
|
99
|
+
|
|
100
|
+
# @see fontId
|
|
94
101
|
def fontId=(v) Axlsx::validate_unsigned_int v; @fontId = v end
|
|
102
|
+
# @see fillId
|
|
95
103
|
def fillId=(v) Axlsx::validate_unsigned_int v; @fillId = v end
|
|
104
|
+
# @see borderId
|
|
96
105
|
def borderId=(v) Axlsx::validate_unsigned_int v; @borderId = v end
|
|
106
|
+
# @see xfId
|
|
97
107
|
def xfId=(v) Axlsx::validate_unsigned_int v; @xfId = v end
|
|
108
|
+
# @see quotePrefix
|
|
98
109
|
def quotePrefix=(v) Axlsx::validate_boolean v; @quotePrefix = v end
|
|
110
|
+
# @see pivotButton
|
|
99
111
|
def pivotButton=(v) Axlsx::validate_boolean v; @pivotButton = v end
|
|
112
|
+
# @see applyNumberFormat
|
|
100
113
|
def applyNumberFormat=(v) Axlsx::validate_boolean v; @applyNumberFormat = v end
|
|
114
|
+
# @see applyFont
|
|
101
115
|
def applyFont=(v) Axlsx::validate_boolean v; @applyFont = v end
|
|
116
|
+
# @see applyFill
|
|
102
117
|
def applyFill=(v) Axlsx::validate_boolean v; @applyFill = v end
|
|
118
|
+
|
|
119
|
+
# @see applyBorder
|
|
103
120
|
def applyBorder=(v) Axlsx::validate_boolean v; @applyBorder = v end
|
|
121
|
+
|
|
122
|
+
# @see applyAlignment
|
|
104
123
|
def applyAlignment=(v) Axlsx::validate_boolean v; @applyAlignment = v end
|
|
124
|
+
|
|
125
|
+
# @see applyProtection
|
|
105
126
|
def applyProtection=(v) Axlsx::validate_boolean v; @applyProtection = v end
|
|
106
127
|
|
|
107
128
|
# Serializes the xf elemen
|
|
@@ -31,7 +31,7 @@ module Axlsx
|
|
|
31
31
|
# @raise [ArugumentError] Raised if the class of the value provided is not in the specified array of types or the block passed returns false
|
|
32
32
|
# @return [Boolean] true if validation succeeds.
|
|
33
33
|
# @see validate_boolean
|
|
34
|
-
def self.validate(name, types, v, other= lambda{|
|
|
34
|
+
def self.validate(name, types, v, other= lambda{|arg| true })
|
|
35
35
|
types = [types] unless types.is_a? Array
|
|
36
36
|
valid_type = false
|
|
37
37
|
if v.class == Class
|
|
@@ -49,7 +49,7 @@ module Axlsx
|
|
|
49
49
|
# @raise [ArgumentError] raised if the value is not a Fixnum or Integer value greater or equal to 0
|
|
50
50
|
# @return [Boolean] true if the data is valid
|
|
51
51
|
def self.validate_unsigned_int(v)
|
|
52
|
-
DataTypeValidator.validate(:unsigned_int, [Fixnum, Integer], v, lambda { |
|
|
52
|
+
DataTypeValidator.validate(:unsigned_int, [Fixnum, Integer], v, lambda { |arg| arg.respond_to?(:>=) && arg >= 0 })
|
|
53
53
|
end
|
|
54
54
|
|
|
55
55
|
# Requires that the value is a Fixnum or Integer
|
|
@@ -63,7 +63,7 @@ module Axlsx
|
|
|
63
63
|
# it must be one of 0, 1, "true", "false", :true, :false, true, false, "0", or "1"
|
|
64
64
|
# @param [Any] v The value validated
|
|
65
65
|
def self.validate_boolean(v)
|
|
66
|
-
DataTypeValidator.validate(:boolean, [Fixnum, String, Integer, Symbol, TrueClass, FalseClass], v, lambda { |
|
|
66
|
+
DataTypeValidator.validate(:boolean, [Fixnum, String, Integer, Symbol, TrueClass, FalseClass], v, lambda { |arg| [0, 1, "true", "false", :true, :false, true, false, "0", "1"].include?(arg) })
|
|
67
67
|
end
|
|
68
68
|
|
|
69
69
|
# Requires that the value is a String
|
data/lib/axlsx/version.rb
CHANGED
|
@@ -65,13 +65,6 @@ require 'axlsx/workbook/worksheet/worksheet.rb'
|
|
|
65
65
|
# @return [Styles]
|
|
66
66
|
attr_reader :styles
|
|
67
67
|
|
|
68
|
-
# The workbook relationships. This is managed automatically by the workbook
|
|
69
|
-
# @return [Relationships]
|
|
70
|
-
attr_reader :relationships
|
|
71
|
-
|
|
72
|
-
# Instance level access to the class variable 1904
|
|
73
|
-
# @return [Boolean]
|
|
74
|
-
attr_accessor :date1904
|
|
75
68
|
|
|
76
69
|
|
|
77
70
|
# Indicates if the epoc date for serialization should be 1904. If false, 1900 is used.
|
|
@@ -89,9 +82,13 @@ require 'axlsx/workbook/worksheet/worksheet.rb'
|
|
|
89
82
|
yield self if block_given?
|
|
90
83
|
end
|
|
91
84
|
|
|
92
|
-
|
|
85
|
+
# Instance level access to the class variable 1904
|
|
86
|
+
# @return [Boolean]
|
|
93
87
|
def date1904() @@date1904; end
|
|
94
88
|
|
|
89
|
+
# see @date1904
|
|
90
|
+
def date1904=(v) Axlsx::validate_boolean v; @@date1904 = v; end
|
|
91
|
+
|
|
95
92
|
# Sets the date1904 attribute to the provided boolean
|
|
96
93
|
# @return [Boolean]
|
|
97
94
|
def self.date1904=(v) Axlsx::validate_boolean v; @@date1904 = v; end
|
|
@@ -109,7 +106,9 @@ require 'axlsx/workbook/worksheet/worksheet.rb'
|
|
|
109
106
|
yield worksheet if block_given?
|
|
110
107
|
worksheet
|
|
111
108
|
end
|
|
112
|
-
|
|
109
|
+
|
|
110
|
+
# The workbook relationships. This is managed automatically by the workbook
|
|
111
|
+
# @return [Relationships]
|
|
113
112
|
def relationships
|
|
114
113
|
r = Relationships.new
|
|
115
114
|
@worksheets.each do |sheet|
|