axlsx 1.0.12 → 1.0.13
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +7 -3
- data/lib/axlsx.rb +57 -0
- data/lib/axlsx/content_type/content_type.rb +23 -0
- data/lib/axlsx/content_type/default.rb +37 -0
- data/lib/axlsx/content_type/override.rb +37 -0
- data/lib/axlsx/doc_props/app.rb +178 -0
- data/lib/axlsx/doc_props/core.rb +34 -0
- data/lib/axlsx/drawing/axis.rb +90 -0
- data/lib/axlsx/drawing/bar_3D_chart.rb +128 -0
- data/lib/axlsx/drawing/bar_series.rb +64 -0
- data/lib/axlsx/drawing/cat_axis.rb +63 -0
- data/lib/axlsx/drawing/cat_axis_data.rb +35 -0
- data/lib/axlsx/drawing/chart.rb +179 -0
- data/lib/axlsx/drawing/drawing.rb +137 -0
- data/lib/axlsx/drawing/graphic_frame.rb +52 -0
- data/lib/axlsx/drawing/line_3D_chart.rb +106 -0
- data/lib/axlsx/drawing/line_series.rb +46 -0
- data/lib/axlsx/drawing/marker.rb +61 -0
- data/lib/axlsx/drawing/one_cell_anchor.rb +89 -0
- data/lib/axlsx/drawing/pic.rb +153 -0
- data/lib/axlsx/drawing/picture_locking.rb +72 -0
- data/lib/axlsx/drawing/picture_locking.rb~ +36 -0
- data/lib/axlsx/drawing/pie_3D_chart.rb +41 -0
- data/lib/axlsx/drawing/pie_series.rb +56 -0
- data/lib/axlsx/drawing/scaling.rb +59 -0
- data/lib/axlsx/drawing/ser_axis.rb +45 -0
- data/lib/axlsx/drawing/series.rb +71 -0
- data/lib/axlsx/drawing/series_title.rb +22 -0
- data/lib/axlsx/drawing/title.rb +61 -0
- data/lib/axlsx/drawing/two_cell_anchor.rb +76 -0
- data/lib/axlsx/drawing/val_axis.rb +34 -0
- data/lib/axlsx/drawing/val_axis_data.rb +28 -0
- data/lib/axlsx/drawing/view_3D.rb +85 -0
- data/lib/axlsx/package.rb +215 -0
- data/lib/axlsx/rels/relationship.rb +44 -0
- data/lib/axlsx/rels/relationships.rb +25 -0
- data/lib/axlsx/stylesheet/border.rb +57 -0
- data/lib/axlsx/stylesheet/border_pr.rb +68 -0
- data/lib/axlsx/stylesheet/cell_alignment.rb +105 -0
- data/lib/axlsx/stylesheet/cell_protection.rb +36 -0
- data/lib/axlsx/stylesheet/cell_style.rb +65 -0
- data/lib/axlsx/stylesheet/color.rb +69 -0
- data/lib/axlsx/stylesheet/fill.rb +32 -0
- data/lib/axlsx/stylesheet/font.rb +139 -0
- data/lib/axlsx/stylesheet/gradient_fill.rb +76 -0
- data/lib/axlsx/stylesheet/gradient_stop.rb +33 -0
- data/lib/axlsx/stylesheet/num_fmt.rb +63 -0
- data/lib/axlsx/stylesheet/pattern_fill.rb +66 -0
- data/lib/axlsx/stylesheet/styles.rb +298 -0
- data/lib/axlsx/stylesheet/table_style.rb +47 -0
- data/lib/axlsx/stylesheet/table_style_element.rb +71 -0
- data/lib/axlsx/stylesheet/table_styles.rb +39 -0
- data/lib/axlsx/stylesheet/xf.rb +138 -0
- data/lib/axlsx/util/constants.rb +220 -0
- data/lib/axlsx/util/parser.rb +43 -0
- data/lib/axlsx/util/parser.rb~ +6 -0
- data/lib/axlsx/util/simple_typed_list.rb +160 -0
- data/lib/axlsx/util/validators.rb +132 -0
- data/lib/axlsx/version.rb +4 -0
- data/lib/axlsx/workbook/#workbook.rb# +165 -0
- data/lib/axlsx/workbook/workbook.rb +160 -0
- data/lib/axlsx/workbook/worksheet/cell.rb +337 -0
- data/lib/axlsx/workbook/worksheet/row.rb +107 -0
- data/lib/axlsx/workbook/worksheet/worksheet.rb +279 -0
- metadata +93 -141
- data/examples/follow_20111202.xlsx +0 -0
- data/test/content_type/tc_content_type.rb +0 -81
- data/test/content_type/tc_default.rb +0 -40
- data/test/content_type/tc_override.rb +0 -40
- data/test/doc_props/tc_app.rb +0 -19
- data/test/doc_props/tc_core.rb +0 -34
- data/test/drawing/tc_axis.rb +0 -40
- data/test/drawing/tc_bar_3D_chart.rb +0 -66
- data/test/drawing/tc_bar_series.rb +0 -34
- data/test/drawing/tc_cat_axis.rb +0 -32
- data/test/drawing/tc_cat_axis_data.rb +0 -18
- data/test/drawing/tc_chart.rb +0 -73
- data/test/drawing/tc_drawing.rb +0 -80
- data/test/drawing/tc_graphic_frame.rb +0 -26
- data/test/drawing/tc_line_3d_chart.rb +0 -48
- data/test/drawing/tc_line_series.rb +0 -27
- data/test/drawing/tc_marker.rb +0 -45
- data/test/drawing/tc_one_cell_anchor.rb +0 -67
- data/test/drawing/tc_pic.rb +0 -71
- data/test/drawing/tc_picture_locking.rb +0 -73
- data/test/drawing/tc_pie_3D_chart.rb +0 -33
- data/test/drawing/tc_pie_series.rb +0 -35
- data/test/drawing/tc_scaling.rb +0 -37
- data/test/drawing/tc_ser_axis.rb +0 -31
- data/test/drawing/tc_series.rb +0 -24
- data/test/drawing/tc_series_title.rb +0 -34
- data/test/drawing/tc_title.rb +0 -34
- data/test/drawing/tc_two_cell_anchor.rb +0 -38
- data/test/drawing/tc_val_axis.rb +0 -25
- data/test/drawing/tc_val_axis_data.rb +0 -18
- data/test/drawing/tc_view_3D.rb +0 -55
- data/test/rels/tc_relationship.rb +0 -16
- data/test/rels/tc_relationships.rb +0 -27
- data/test/stylesheet/tc_border.rb +0 -38
- data/test/stylesheet/tc_border_pr.rb +0 -33
- data/test/stylesheet/tc_cell_alignment.rb +0 -77
- data/test/stylesheet/tc_cell_protection.rb +0 -30
- data/test/stylesheet/tc_cell_style.rb +0 -58
- data/test/stylesheet/tc_color.rb +0 -38
- data/test/stylesheet/tc_fill.rb +0 -19
- data/test/stylesheet/tc_font.rb +0 -114
- data/test/stylesheet/tc_gradient_fill.rb +0 -65
- data/test/stylesheet/tc_gradient_stop.rb +0 -32
- data/test/stylesheet/tc_num_fmt.rb +0 -31
- data/test/stylesheet/tc_pattern_fill.rb +0 -38
- data/test/stylesheet/tc_styles.rb +0 -52
- data/test/stylesheet/tc_table_style.rb +0 -37
- data/test/stylesheet/tc_table_style_element.rb +0 -37
- data/test/stylesheet/tc_table_styles.rb +0 -30
- data/test/stylesheet/tc_xf.rb +0 -121
- data/test/tc_package.rb +0 -68
- data/test/util/tc_simple_typed_list.rb +0 -66
- data/test/util/tc_validators.rb +0 -76
- data/test/workbook/tc_workbook.rb +0 -60
- data/test/workbook/worksheet/tc_cell.rb +0 -179
- data/test/workbook/worksheet/tc_row.rb +0 -36
- data/test/workbook/worksheet/tc_worksheet.rb +0 -138
@@ -0,0 +1,44 @@
|
|
1
|
+
module Axlsx
|
2
|
+
# A relationship defines a reference between package parts.
|
3
|
+
# @note Packages automatcially manage relationships.
|
4
|
+
class Relationship
|
5
|
+
|
6
|
+
# The location of the relationship target
|
7
|
+
# @return [String]
|
8
|
+
attr_reader :Target
|
9
|
+
|
10
|
+
# The type of relationship
|
11
|
+
# @note Supported types are defined as constants in Axlsx:
|
12
|
+
# @see XML_NS_R
|
13
|
+
# @see TABLE_R
|
14
|
+
# @see WORKBOOK_R
|
15
|
+
# @see WORKSHEET_R
|
16
|
+
# @see APP_R
|
17
|
+
# @see RELS_R
|
18
|
+
# @see CORE_R
|
19
|
+
# @see STYLES_R
|
20
|
+
# @see CHART_R
|
21
|
+
# @see DRAWING_R
|
22
|
+
# @return [String]
|
23
|
+
attr_reader :Type
|
24
|
+
def initialize(type, target)
|
25
|
+
self.Target=target
|
26
|
+
self.Type=type
|
27
|
+
end
|
28
|
+
|
29
|
+
# @see Target
|
30
|
+
def Target=(v) Axlsx::validate_string v; @Target = v end
|
31
|
+
# @see Type
|
32
|
+
def Type=(v) Axlsx::validate_relationship_type v; @Type = v end
|
33
|
+
|
34
|
+
# Serializes the relationship
|
35
|
+
# @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to.
|
36
|
+
# @param [String] rId the reference id of the object.
|
37
|
+
# @return [String]
|
38
|
+
def to_xml(xml, rId)
|
39
|
+
h = self.instance_values
|
40
|
+
h[:Id] = rId
|
41
|
+
xml.Relationship(h)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Axlsx
|
2
|
+
require 'axlsx/rels/relationship.rb'
|
3
|
+
|
4
|
+
# Relationships are a collection of Relations that define how package parts are related.
|
5
|
+
# @note The package automatically manages releationships.
|
6
|
+
class Relationships < SimpleTypedList
|
7
|
+
|
8
|
+
# Creates a new Relationships collection based on SimpleTypedList
|
9
|
+
def initialize
|
10
|
+
super Relationship
|
11
|
+
end
|
12
|
+
|
13
|
+
# Serializes the relationships document.
|
14
|
+
# @return [String]
|
15
|
+
def to_xml()
|
16
|
+
builder = Nokogiri::XML::Builder.new(:encoding => ENCODING) do |xml|
|
17
|
+
xml.Relationships(:xmlns => Axlsx::RELS_R) {
|
18
|
+
each_with_index { |rel, index| rel.to_xml(xml, "rId#{index+1}") }
|
19
|
+
}
|
20
|
+
end
|
21
|
+
builder.to_xml
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
module Axlsx
|
2
|
+
# This class details a border used in Office Open XML spreadsheet styles.
|
3
|
+
class Border
|
4
|
+
|
5
|
+
# @return [Boolean] The diagonal up property for the border that indicates if the border should include a diagonal line from the bottom left to the top right of the cell.
|
6
|
+
attr_reader :diagonalUp
|
7
|
+
|
8
|
+
# @return [Boolean] The diagonal down property for the border that indicates if the border should include a diagonal line from the top left to the top right of the cell.
|
9
|
+
attr_reader :diagonalDown
|
10
|
+
|
11
|
+
# @return [Boolean] The outline property for the border indicating that top, left, right and bottom borders should only be applied to the outside border of a range of cells.
|
12
|
+
attr_reader :outline
|
13
|
+
|
14
|
+
# @return [SimpleTypedList] A list of BorderPr objects for this border.
|
15
|
+
attr_reader :prs
|
16
|
+
|
17
|
+
# Creates a new Border object
|
18
|
+
# @option options [Boolean] diagonalUp
|
19
|
+
# @option options [Boolean] diagonalDown
|
20
|
+
# @option options [Boolean] outline
|
21
|
+
# @example Making a border
|
22
|
+
# p = Package.new
|
23
|
+
# red_border = Border.new
|
24
|
+
# [:left, :right, :top, :bottom].each do |item|
|
25
|
+
# red_border.prs << BorderPr.new(:name=>item, :style=>:thin, :color=>Color.new(:rgb=>"FFFF0000")) #
|
26
|
+
# end
|
27
|
+
# # this sets red_border to be the index for the created border.
|
28
|
+
# red_border = p.workbook.styles.@borders << red_border
|
29
|
+
# #used in row creation as follows. This will add a red border to each of the cells in the row.
|
30
|
+
# p.workbook.add_worksheet.rows << :values=>[1,2,3] :style=>red_border
|
31
|
+
def initialize(options={})
|
32
|
+
@prs = SimpleTypedList.new BorderPr
|
33
|
+
options.each do |o|
|
34
|
+
self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# @see diagonalUp
|
39
|
+
def diagonalUp=(v) Axlsx::validate_boolean v; @diagonalUp = v end
|
40
|
+
# @see diagonalDown
|
41
|
+
def diagonalDown=(v) Axlsx::validate_boolean v; @diagonalDown = v end
|
42
|
+
# @see outline
|
43
|
+
def outline=(v) Axlsx::validate_boolean v; @outline = v end
|
44
|
+
|
45
|
+
# Serializes the border element
|
46
|
+
# @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to.
|
47
|
+
def to_xml(xml)
|
48
|
+
xml.border(self.instance_values.select{ |k,v| [:diagonalUp, :diagonalDown, :outline].include? k }) {
|
49
|
+
[:start, :end, :left, :right, :top, :bottom, :diagonal, :vertical, :horizontal].each do |k|
|
50
|
+
@prs.select { |pr| pr.name == k }.each do |part|
|
51
|
+
part.to_xml(xml)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
}
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
module Axlsx
|
2
|
+
# A border part.
|
3
|
+
class BorderPr
|
4
|
+
|
5
|
+
# @return [Color] The color of this border part.
|
6
|
+
attr_reader :color
|
7
|
+
|
8
|
+
# @return [Symbol] The syle of this border part.
|
9
|
+
# @note
|
10
|
+
# The following are allowed
|
11
|
+
# :none
|
12
|
+
# :thin
|
13
|
+
# :medium
|
14
|
+
# :dashed
|
15
|
+
# :dotted
|
16
|
+
# :thick
|
17
|
+
# :double
|
18
|
+
# :hair
|
19
|
+
# :mediumDashed
|
20
|
+
# :dashDot
|
21
|
+
# :mediumDashDot
|
22
|
+
# :dashDotDot
|
23
|
+
# :mediumDashDotDot
|
24
|
+
# :slantDashDot
|
25
|
+
attr_reader :style
|
26
|
+
|
27
|
+
# @return [Symbol] The name of this border part
|
28
|
+
# @note
|
29
|
+
# The following are allowed
|
30
|
+
# :start
|
31
|
+
# :end
|
32
|
+
# :left
|
33
|
+
# :right
|
34
|
+
# :top
|
35
|
+
# :bottom
|
36
|
+
# :diagonal
|
37
|
+
# :vertical
|
38
|
+
# :horizontal
|
39
|
+
attr_reader :name
|
40
|
+
|
41
|
+
# Creates a new Border Part Object
|
42
|
+
# @option options [Color] color
|
43
|
+
# @option options [Symbol] name
|
44
|
+
# @option options [Symbol] style
|
45
|
+
# @see Axlsx::Border
|
46
|
+
def initialize(options={})
|
47
|
+
options.each do |o|
|
48
|
+
self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
# @see name
|
53
|
+
def name=(v) RestrictionValidator.validate "BorderPr.name", [:start, :end, :left, :right, :top, :bottom, :diagonal, :vertical, :horizontal], v; @name = v end
|
54
|
+
# @see color
|
55
|
+
def color=(v) DataTypeValidator.validate(:color, Color, v); @color = v end
|
56
|
+
# @see style
|
57
|
+
def style=(v) RestrictionValidator.validate "BorderPr.style", [:none, :thin, :medium, :dashed, :dotted, :thick, :double, :hair, :mediumDashed, :dashDot, :mediumDashDot, :dashDotDot, :mediumDashDotDot, :slantDashDot], v; @style = v end
|
58
|
+
|
59
|
+
# Serializes the border part
|
60
|
+
# @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to.
|
61
|
+
# @return [String]
|
62
|
+
def to_xml(xml)
|
63
|
+
xml.send(@name, :style => @style) {
|
64
|
+
@color.to_xml(xml) if @color.is_a? Color
|
65
|
+
}
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
module Axlsx
|
2
|
+
# CellAlignment stores information about the cell alignment of a style Xf Object.
|
3
|
+
# @note Using Styles#add_style is the recommended way to manage cell alignment.
|
4
|
+
# @see Styles#add_style
|
5
|
+
class CellAlignment
|
6
|
+
# The horizontal alignment of the cell.
|
7
|
+
# @note
|
8
|
+
# The horizontal cell alignement style must be one of
|
9
|
+
# :general
|
10
|
+
# :left
|
11
|
+
# :center
|
12
|
+
# :right
|
13
|
+
# :fill
|
14
|
+
# :justify
|
15
|
+
# :centerContinuous
|
16
|
+
# :distributed
|
17
|
+
# @return [Symbol]
|
18
|
+
attr_reader :horizontal
|
19
|
+
|
20
|
+
# The vertical alignment of the cell.
|
21
|
+
# @note
|
22
|
+
# The vertical cell allingment style must be one of the following:
|
23
|
+
# :top
|
24
|
+
# :center
|
25
|
+
# :bottom
|
26
|
+
# :justify
|
27
|
+
# :distributed
|
28
|
+
# @return [Symbol]
|
29
|
+
attr_reader :vertical
|
30
|
+
|
31
|
+
# The textRotation of the cell.
|
32
|
+
# @return [Integer]
|
33
|
+
attr_reader :textRotation
|
34
|
+
|
35
|
+
# Indicate if the text of the cell should wrap
|
36
|
+
# @return [Boolean]
|
37
|
+
attr_reader :wrapText
|
38
|
+
|
39
|
+
# The amount of indent
|
40
|
+
# @return [Integer]
|
41
|
+
attr_reader :indent
|
42
|
+
|
43
|
+
# The amount of relativeIndent
|
44
|
+
# @return [Integer]
|
45
|
+
attr_reader :relativeIndent
|
46
|
+
|
47
|
+
# Indicate if the last line should be justified.
|
48
|
+
# @return [Boolean]
|
49
|
+
attr_reader :justifyLastLine
|
50
|
+
|
51
|
+
# Indicate if the text should be shrunk to the fit in the cell.
|
52
|
+
# @return [Boolean]
|
53
|
+
attr_reader :shrinkToFit
|
54
|
+
|
55
|
+
# The reading order of the text
|
56
|
+
# 0 Context Dependent
|
57
|
+
# 1 Left-to-Right
|
58
|
+
# 2 Right-to-Left
|
59
|
+
# @return [Integer]
|
60
|
+
attr_reader :readingOrder
|
61
|
+
|
62
|
+
# Create a new cell_alignment object
|
63
|
+
# @option options [Symbol] horizontal
|
64
|
+
# @option options [Symbol] vertical
|
65
|
+
# @option options [Integer] textRotation
|
66
|
+
# @option options [Boolean] wrapText
|
67
|
+
# @option options [Integer] indent
|
68
|
+
# @option options [Integer] relativeIndent
|
69
|
+
# @option options [Boolean] justifyLastLine
|
70
|
+
# @option options [Boolean] shrinkToFit
|
71
|
+
# @option options [Integer] readingOrder
|
72
|
+
def initialize(options={})
|
73
|
+
options.each do |o|
|
74
|
+
self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
# @see horizontal
|
79
|
+
def horizontal=(v) Axlsx::validate_horizontal_alignment v; @horizontal = v end
|
80
|
+
# @see vertical
|
81
|
+
def vertical=(v) Axlsx::validate_vertical_alignment v; @vertical = v end
|
82
|
+
# @see textRotation
|
83
|
+
def textRotation=(v) Axlsx::validate_unsigned_int v; @textRotation = v end
|
84
|
+
# @see wrapText
|
85
|
+
def wrapText=(v) Axlsx::validate_boolean v; @wrapText = v end
|
86
|
+
# @see indent
|
87
|
+
def indent=(v) Axlsx::validate_unsigned_int v; @indent = v end
|
88
|
+
# @see relativeIndent
|
89
|
+
def relativeIndent=(v) Axlsx::validate_int v; @relativeIndent = v end
|
90
|
+
# @see justifyLastLine
|
91
|
+
def justifyLastLine=(v) Axlsx::validate_boolean v; @justifyLastLine = v end
|
92
|
+
# @see shrinkToFit
|
93
|
+
def shrinkToFit=(v) Axlsx::validate_boolean v; @shrinkToFit = v end
|
94
|
+
# @see readingOrder
|
95
|
+
def readingOrder=(v) Axlsx::validate_unsigned_int v; @readingOrder = v end
|
96
|
+
|
97
|
+
# Serializes the cell alignment
|
98
|
+
# @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to.
|
99
|
+
# @return [String]
|
100
|
+
def to_xml(xml)
|
101
|
+
xml.alignment(self.instance_values)
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|
105
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Axlsx
|
2
|
+
# CellProtection stores information about locking or hiding cells in spreadsheet.
|
3
|
+
# @note Using Styles#add_style is the recommended way to manage cell protection.
|
4
|
+
# @see Styles#add_style
|
5
|
+
class CellProtection
|
6
|
+
|
7
|
+
# specifies locking for cells that have the style containing this protection
|
8
|
+
# @return [Boolean]
|
9
|
+
attr_reader :hidden
|
10
|
+
|
11
|
+
# specifies if the cells that have the style containing this protection
|
12
|
+
# @return [Boolean]
|
13
|
+
attr_reader :locked
|
14
|
+
|
15
|
+
# Creates a new CellProtection
|
16
|
+
# @option options [Boolean] hidden value for hidden protection
|
17
|
+
# @option options [Boolean] locked value for locked protection
|
18
|
+
def initialize(options={})
|
19
|
+
options.each do |o|
|
20
|
+
self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# @see hidden
|
25
|
+
def hidden=(v) Axlsx::validate_boolean v; @hidden = v end
|
26
|
+
# @see locked
|
27
|
+
def locked=(v) Axlsx::validate_boolean v; @locked = v end
|
28
|
+
|
29
|
+
# Serializes the cell protection
|
30
|
+
# @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to.
|
31
|
+
# @return [String]
|
32
|
+
def to_xml(xml)
|
33
|
+
xml.protection(self.instance_values)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
module Axlsx
|
2
|
+
# CellStyle defines named styles that reference defined formatting records and can be used in your worksheet.
|
3
|
+
# @note Using Styles#add_style is the recommended way to manage cell styling.
|
4
|
+
# @see Styles#add_style
|
5
|
+
class CellStyle
|
6
|
+
# The name of this cell style
|
7
|
+
# @return [String]
|
8
|
+
attr_reader :name
|
9
|
+
|
10
|
+
# The formatting record id this named style utilizes
|
11
|
+
# @return [Integer]
|
12
|
+
# @see Axlsx::Xf
|
13
|
+
attr_reader :xfId
|
14
|
+
|
15
|
+
# The buildinId to use when this named style is applied
|
16
|
+
# @return [Integer]
|
17
|
+
# @see Axlsx::NumFmt
|
18
|
+
attr_reader :builtinId
|
19
|
+
|
20
|
+
# Determines if this formatting is for an outline style, and what level of the outline it is to be applied to.
|
21
|
+
# @return [Integer]
|
22
|
+
attr_reader :iLevel
|
23
|
+
|
24
|
+
# Determines if this named style should show in the list of styles when using excel
|
25
|
+
# @return [Boolean]
|
26
|
+
attr_reader :hidden
|
27
|
+
|
28
|
+
# Indicates that the build in style reference has been customized.
|
29
|
+
# @return [Boolean]
|
30
|
+
attr_reader :customBuiltin
|
31
|
+
|
32
|
+
# Creats a new CellStyle object
|
33
|
+
# @option options [String] name
|
34
|
+
# @option options [Integer] xfId
|
35
|
+
# @option options [Integer] buildinId
|
36
|
+
# @option options [Integer] iLevel
|
37
|
+
# @option options [Boolean] hidden
|
38
|
+
# @option options [Boolean] customBuiltIn
|
39
|
+
def initialize(options={})
|
40
|
+
options.each do |o|
|
41
|
+
self.send("#{o[0]}=", o[1]) if self.respond_to? o[0]
|
42
|
+
end
|
43
|
+
end
|
44
|
+
# @see name
|
45
|
+
def name=(v) Axlsx::validate_string v; @name = v end
|
46
|
+
# @see xfId
|
47
|
+
def xfId=(v) Axlsx::validate_unsigned_int v; @xfId = v end
|
48
|
+
# @see builtinId
|
49
|
+
def builtinId=(v) Axlsx::validate_unsigned_int v; @builtinId = v end
|
50
|
+
# @see iLivel
|
51
|
+
def iLevel=(v) Axlsx::validate_unsigned_int v; @iLevel = v end
|
52
|
+
# @see hidden
|
53
|
+
def hidden=(v) Axlsx::validate_boolean v; @hidden = v end
|
54
|
+
# @see customBuiltin
|
55
|
+
def customBuiltin=(v) Axlsx::validate_boolean v; @customBuiltin = v end
|
56
|
+
|
57
|
+
# Serializes the cell style
|
58
|
+
# @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to.
|
59
|
+
# @return [String]
|
60
|
+
def to_xml(xml)
|
61
|
+
xml.cellStyle(self.instance_values)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
module Axlsx
|
2
|
+
# The color class represents a color used for borders, fills an fonts
|
3
|
+
class Color
|
4
|
+
# Determines if the color is system color dependant
|
5
|
+
# @return [Boolean]
|
6
|
+
attr_reader :auto
|
7
|
+
|
8
|
+
# The color as defined in rgb terms.
|
9
|
+
# @note
|
10
|
+
# rgb colors need to conform to ST_UnsignedIntHex. That basically means put 'FF' before you color
|
11
|
+
# When assigning the rgb value the behavior is much like CSS selectors and can use shorthand versions as follows:
|
12
|
+
# If you provide a two character value it will be repeated for each r, g, b assignment
|
13
|
+
# If you provide data that is not 2 characters in length, and is less than 8 characters it will be padded with "F"
|
14
|
+
# @example
|
15
|
+
# Color.new :rgb => "FF000000"
|
16
|
+
# => #<Axlsx::Color:0x102106b68 @rgb="FF000000">
|
17
|
+
# Color.new :rgb => "0A"
|
18
|
+
# => #<Axlsx::Color:0x102106b68 @rgb="FF0A0A0A">
|
19
|
+
# Color.new :rgb => "00BB"
|
20
|
+
# => #<Axlsx::Color:0x102106b68 @rgb="FFFF00BB">
|
21
|
+
# @return [String]
|
22
|
+
attr_reader :rgb
|
23
|
+
|
24
|
+
# no support for theme just yet
|
25
|
+
# @return [Integer]
|
26
|
+
#attr_reader :theme
|
27
|
+
|
28
|
+
# The tint value.
|
29
|
+
# @note valid values are between -1.0 and 1.0
|
30
|
+
# @return [Float]
|
31
|
+
attr_reader :tint
|
32
|
+
|
33
|
+
# Creates a new Color object
|
34
|
+
# @option options [Boolean] auto
|
35
|
+
# @option options [String] rgb
|
36
|
+
# @option options [Float] tint
|
37
|
+
def initialize(options={})
|
38
|
+
@rgb = "FF000000"
|
39
|
+
options.each do |o|
|
40
|
+
self.send("#{o[0]}=", o[1]) if self.respond_to? o[0]
|
41
|
+
end
|
42
|
+
end
|
43
|
+
# @see auto
|
44
|
+
def auto=(v) Axlsx::validate_boolean v; @auto = v end
|
45
|
+
# @see color
|
46
|
+
def rgb=(v)
|
47
|
+
Axlsx::validate_string(v)
|
48
|
+
v.upcase!
|
49
|
+
v = v * 3 if v.size == 2
|
50
|
+
v = v.rjust(8, 'FF')
|
51
|
+
raise ArgumentError, "Invalid color rgb value: #{v}." unless v.match(/[0-9A-F]{8}/)
|
52
|
+
@rgb = v
|
53
|
+
end
|
54
|
+
# @see tint
|
55
|
+
def tint=(v) Axlsx::validate_float v; @tint = v end
|
56
|
+
|
57
|
+
# This version does not support themes
|
58
|
+
# def theme=(v) Axlsx::validate_unsigned_integer v; @theme = v end
|
59
|
+
|
60
|
+
# Indexed colors are for backward compatability which I am choosing not to support
|
61
|
+
# def indexed=(v) Axlsx::validate_unsigned_integer v; @indexed = v end
|
62
|
+
|
63
|
+
|
64
|
+
# Serializes the color
|
65
|
+
# @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to.
|
66
|
+
# @return [String]
|
67
|
+
def to_xml(xml) xml.color(self.instance_values) end
|
68
|
+
end
|
69
|
+
end
|