axlsx 2.1.0.pre → 3.0.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +17 -20
- data/Rakefile +0 -1
- data/examples/conditional_formatting/example_conditional_formatting.rb +15 -0
- data/examples/example.rb +31 -1
- data/lib/axlsx.rb +9 -4
- data/lib/axlsx/drawing/area_chart.rb +99 -0
- data/lib/axlsx/drawing/area_series.rb +110 -0
- data/lib/axlsx/drawing/bar_chart.rb +143 -0
- data/lib/axlsx/drawing/chart.rb +8 -1
- data/lib/axlsx/drawing/d_lbls.rb +3 -3
- data/lib/axlsx/drawing/drawing.rb +3 -0
- data/lib/axlsx/drawing/line_series.rb +18 -1
- data/lib/axlsx/drawing/num_val.rb +3 -1
- data/lib/axlsx/drawing/one_cell_anchor.rb +2 -1
- data/lib/axlsx/drawing/pic.rb +24 -17
- data/lib/axlsx/drawing/scaling.rb +2 -2
- data/lib/axlsx/drawing/scatter_series.rb +16 -2
- data/lib/axlsx/drawing/str_val.rb +3 -1
- data/lib/axlsx/drawing/title.rb +19 -1
- data/lib/axlsx/drawing/two_cell_anchor.rb +6 -1
- data/lib/axlsx/drawing/view_3D.rb +2 -2
- data/lib/axlsx/package.rb +7 -16
- data/lib/axlsx/rels/relationships.rb +5 -2
- data/lib/axlsx/stylesheet/num_fmt.rb +9 -0
- data/lib/axlsx/stylesheet/styles.rb +1 -1
- data/lib/axlsx/util/constants.rb +8 -5
- data/lib/axlsx/util/mime_type_utils.rb +11 -0
- data/lib/axlsx/util/simple_typed_list.rb +1 -1
- data/lib/axlsx/util/validators.rb +14 -9
- data/lib/axlsx/version.rb +1 -1
- data/lib/axlsx/workbook/workbook.rb +19 -1
- data/lib/axlsx/workbook/workbook_view.rb +5 -3
- data/lib/axlsx/workbook/worksheet/cell.rb +26 -19
- data/lib/axlsx/workbook/worksheet/cell_serializer.rb +15 -5
- data/lib/axlsx/workbook/worksheet/cfvos.rb +3 -0
- data/lib/axlsx/workbook/worksheet/cols.rb +5 -2
- data/lib/axlsx/workbook/worksheet/merged_cells.rb +2 -0
- data/lib/axlsx/workbook/worksheet/outline_pr.rb +33 -0
- data/lib/axlsx/workbook/worksheet/pivot_table.rb +36 -13
- data/lib/axlsx/workbook/worksheet/protected_ranges.rb +4 -1
- data/lib/axlsx/workbook/worksheet/rich_text.rb +23 -3
- data/lib/axlsx/workbook/worksheet/rich_text_run.rb +28 -32
- data/lib/axlsx/workbook/worksheet/row.rb +7 -0
- data/lib/axlsx/workbook/worksheet/sheet_pr.rb +21 -3
- data/lib/axlsx/workbook/worksheet/tables.rb +3 -0
- data/lib/axlsx/workbook/worksheet/worksheet.rb +8 -51
- data/lib/axlsx/workbook/worksheet/worksheet_drawing.rb +10 -10
- data/test/axlsx.qcachegrind +2226 -0
- data/test/drawing/tc_area_chart.rb +39 -0
- data/test/drawing/tc_area_series.rb +71 -0
- data/test/drawing/tc_bar_chart.rb +71 -0
- data/test/drawing/tc_chart.rb +23 -10
- data/test/drawing/tc_drawing.rb +2 -2
- data/test/drawing/tc_line_series.rb +38 -5
- data/test/drawing/tc_pic.rb +11 -19
- data/test/drawing/tc_scatter_series.rb +16 -5
- data/test/drawing/tc_str_val.rb +9 -0
- data/test/drawing/tc_title.rb +5 -0
- data/test/stylesheet/tc_styles.rb +2 -2
- data/test/tc_axlsx.rb +31 -0
- data/test/tc_helper.rb +3 -1
- data/test/tc_package.rb +12 -0
- data/test/util/tc_mime_type_utils.rb +13 -0
- data/test/util/tc_simple_typed_list.rb +1 -1
- data/test/util/tc_validators.rb +34 -10
- data/test/workbook/tc_shared_strings_table.rb +16 -1
- data/test/workbook/tc_workbook.rb +22 -1
- data/test/workbook/worksheet/tc_cell.rb +53 -11
- data/test/workbook/worksheet/tc_outline_pr.rb +19 -0
- data/test/workbook/worksheet/tc_pivot_table.rb +21 -6
- data/test/workbook/worksheet/tc_rich_text_run.rb +11 -11
- data/test/workbook/worksheet/tc_row.rb +5 -0
- data/test/workbook/worksheet/tc_sheet_pr.rb +26 -4
- data/test/workbook/worksheet/tc_table.rb +2 -3
- data/test/workbook/worksheet/tc_worksheet.rb +53 -38
- metadata +72 -20
- data/examples/IMAGE1UP.JPEG +0 -0
- data/lib/axlsx/util/string.rb +0 -7
data/lib/axlsx/drawing/chart.rb
CHANGED
@@ -56,7 +56,7 @@ module Axlsx
|
|
56
56
|
# Indicates that colors should be varied by datum
|
57
57
|
# @return [Boolean]
|
58
58
|
attr_reader :vary_colors
|
59
|
-
|
59
|
+
|
60
60
|
# Configures the vary_colors options for this chart
|
61
61
|
# @param [Boolean] v The value to set
|
62
62
|
def vary_colors=(v) Axlsx::validate_boolean(v); @vary_colors = v; end
|
@@ -128,6 +128,13 @@ module Axlsx
|
|
128
128
|
end
|
129
129
|
end
|
130
130
|
|
131
|
+
# The size of the Title object of the chart.
|
132
|
+
# @param [String] v The size for the title object
|
133
|
+
# @see Title
|
134
|
+
def title_size=(v)
|
135
|
+
@title.text_size = v unless v.to_s.empty?
|
136
|
+
end
|
137
|
+
|
131
138
|
# Show the legend in the chart
|
132
139
|
# @param [Boolean] v
|
133
140
|
# @return [Boolean]
|
data/lib/axlsx/drawing/d_lbls.rb
CHANGED
@@ -49,7 +49,7 @@ module Axlsx
|
|
49
49
|
# @see d_lbl_pos= for a list of allowed values
|
50
50
|
# @return [Symbol]
|
51
51
|
def d_lbl_pos
|
52
|
-
return unless @chart_type
|
52
|
+
return unless [Pie3DChart, LineChart].include? @chart_type
|
53
53
|
@d_lbl_pos ||= :bestFit
|
54
54
|
end
|
55
55
|
|
@@ -60,7 +60,7 @@ module Axlsx
|
|
60
60
|
# The default is :bestFit
|
61
61
|
# @param [Symbol] label_position the postion you want to use.
|
62
62
|
def d_lbl_pos=(label_position)
|
63
|
-
return unless @chart_type
|
63
|
+
return unless [Pie3DChart, LineChart].include? @chart_type
|
64
64
|
Axlsx::RestrictionValidator.validate 'DLbls#d_lbl_pos', [:bestFit, :b, :ctr, :inBase, :inEnd, :l, :outEnd, :r, :t], label_position
|
65
65
|
@d_lbl_pos = label_position
|
66
66
|
end
|
@@ -80,7 +80,7 @@ module Axlsx
|
|
80
80
|
|
81
81
|
# nills out d_lbl_pos and show_leader_lines as these attributes, while valid in the spec actually chrash excel for any chart type other than pie charts.
|
82
82
|
def validate_attributes_for_chart_type
|
83
|
-
return if @chart_type
|
83
|
+
return if [Pie3DChart, LineChart].include? @chart_type
|
84
84
|
@d_lbl_pos = nil
|
85
85
|
@show_leader_lines = nil
|
86
86
|
end
|
@@ -9,6 +9,7 @@ module Axlsx
|
|
9
9
|
require 'axlsx/drawing/line_series.rb'
|
10
10
|
require 'axlsx/drawing/scatter_series.rb'
|
11
11
|
require 'axlsx/drawing/bubble_series.rb'
|
12
|
+
require 'axlsx/drawing/area_series.rb'
|
12
13
|
|
13
14
|
require 'axlsx/drawing/scaling.rb'
|
14
15
|
require 'axlsx/drawing/axis.rb'
|
@@ -35,10 +36,12 @@ module Axlsx
|
|
35
36
|
require 'axlsx/drawing/chart.rb'
|
36
37
|
require 'axlsx/drawing/pie_3D_chart.rb'
|
37
38
|
require 'axlsx/drawing/bar_3D_chart.rb'
|
39
|
+
require 'axlsx/drawing/bar_chart.rb'
|
38
40
|
require 'axlsx/drawing/line_chart.rb'
|
39
41
|
require 'axlsx/drawing/line_3D_chart.rb'
|
40
42
|
require 'axlsx/drawing/scatter_chart.rb'
|
41
43
|
require 'axlsx/drawing/bubble_chart.rb'
|
44
|
+
require 'axlsx/drawing/area_chart.rb'
|
42
45
|
|
43
46
|
require 'axlsx/drawing/picture_locking.rb'
|
44
47
|
require 'axlsx/drawing/pic.rb'
|
@@ -23,6 +23,10 @@ module Axlsx
|
|
23
23
|
# @return [Boolean]
|
24
24
|
attr_reader :show_marker
|
25
25
|
|
26
|
+
# custom marker symbol
|
27
|
+
# @return [String]
|
28
|
+
attr_reader :marker_symbol
|
29
|
+
|
26
30
|
# line smoothing on values
|
27
31
|
# @return [Boolean]
|
28
32
|
attr_reader :smooth
|
@@ -33,6 +37,7 @@ module Axlsx
|
|
33
37
|
# @param [Chart] chart
|
34
38
|
def initialize(chart, options={})
|
35
39
|
@show_marker = false
|
40
|
+
@marker_symbol = options[:marker_symbol] ? options[:marker_symbol] : :default
|
36
41
|
@smooth = false
|
37
42
|
@labels, @data = nil, nil
|
38
43
|
super(chart, options)
|
@@ -51,6 +56,12 @@ module Axlsx
|
|
51
56
|
@show_marker = v
|
52
57
|
end
|
53
58
|
|
59
|
+
# @see marker_symbol
|
60
|
+
def marker_symbol=(v)
|
61
|
+
Axlsx::validate_marker_symbol(v)
|
62
|
+
@marker_symbol = v
|
63
|
+
end
|
64
|
+
|
54
65
|
# @see smooth
|
55
66
|
def smooth=(v)
|
56
67
|
Axlsx::validate_boolean(v)
|
@@ -74,7 +85,13 @@ module Axlsx
|
|
74
85
|
str << '<a:round/>'
|
75
86
|
str << '</c:spPr>'
|
76
87
|
end
|
77
|
-
|
88
|
+
|
89
|
+
if !@show_marker
|
90
|
+
str << '<c:marker><c:symbol val="none"/></c:marker>'
|
91
|
+
elsif @marker_symbol != :default
|
92
|
+
str << '<c:marker><c:symbol val="' + @marker_symbol.to_s + '"/></c:marker>'
|
93
|
+
end
|
94
|
+
|
78
95
|
@labels.to_xml_string(str) unless @labels.nil?
|
79
96
|
@data.to_xml_string(str) unless @data.nil?
|
80
97
|
str << ('<c:smooth val="' << ((smooth) ? '1' : '0') << '"/>')
|
@@ -26,7 +26,9 @@ module Axlsx
|
|
26
26
|
# serialize the object
|
27
27
|
def to_xml_string(idx, str = "")
|
28
28
|
Axlsx::validate_unsigned_int(idx)
|
29
|
-
|
29
|
+
if !v.to_s.empty?
|
30
|
+
str << ('<c:pt idx="' << idx.to_s << '" formatCode="' << format_code << '"><c:v>' << v.to_s << '</c:v></c:pt>')
|
31
|
+
end
|
30
32
|
end
|
31
33
|
end
|
32
34
|
end
|
@@ -7,7 +7,7 @@ module Axlsx
|
|
7
7
|
class OneCellAnchor
|
8
8
|
|
9
9
|
include Axlsx::OptionsParser
|
10
|
-
|
10
|
+
|
11
11
|
# Creates a new OneCellAnchor object and an Pic associated with it.
|
12
12
|
# @param [Drawing] drawing
|
13
13
|
# @option options [Array] start_at the col, row to start at
|
@@ -23,6 +23,7 @@ module Axlsx
|
|
23
23
|
drawing.anchors << self
|
24
24
|
@from = Marker.new
|
25
25
|
parse_options options
|
26
|
+
start_at(*options[:start_at]) if options[:start_at]
|
26
27
|
@object = Pic.new(self, options)
|
27
28
|
end
|
28
29
|
|
data/lib/axlsx/drawing/pic.rb
CHANGED
@@ -9,12 +9,13 @@ module Axlsx
|
|
9
9
|
|
10
10
|
# Creates a new Pic(ture) object
|
11
11
|
# @param [Anchor] anchor the anchor that holds this image
|
12
|
-
# @option options [String] name
|
13
|
-
# @option options [String] descr
|
14
|
-
# @option options [String] image_src
|
15
|
-
# @option options [Array] start_at
|
16
|
-
# @option options [
|
17
|
-
# @option options [
|
12
|
+
# @option options [String] :name
|
13
|
+
# @option options [String] :descr
|
14
|
+
# @option options [String] :image_src
|
15
|
+
# @option options [Array] :start_at
|
16
|
+
# @option options [Integer] :width
|
17
|
+
# @option options [Integer] :height
|
18
|
+
# @option options [Float] :opacity - set the picture opacity, accepts a value between 0.0 and 1.0
|
18
19
|
def initialize(anchor, options={})
|
19
20
|
@anchor = anchor
|
20
21
|
@hyperlink = nil
|
@@ -23,10 +24,11 @@ module Axlsx
|
|
23
24
|
start_at(*options[:start_at]) if options[:start_at]
|
24
25
|
yield self if block_given?
|
25
26
|
@picture_locking = PictureLocking.new(options)
|
27
|
+
@opacity = (options[:opacity] * 100000).round if options[:opacity]
|
26
28
|
end
|
27
29
|
|
28
|
-
# allowed
|
29
|
-
|
30
|
+
# allowed mime types
|
31
|
+
ALLOWED_MIME_TYPES = %w(image/jpeg image/png image/gif)
|
30
32
|
|
31
33
|
# The name to use for this picture
|
32
34
|
# @return [String]
|
@@ -50,24 +52,28 @@ module Axlsx
|
|
50
52
|
|
51
53
|
attr_reader :hyperlink
|
52
54
|
|
55
|
+
# Picture opacity
|
56
|
+
# @return [Integer]
|
57
|
+
attr_reader :opacity
|
58
|
+
|
53
59
|
# sets or updates a hyperlink for this image.
|
54
60
|
# @param [String] v The href value for the hyper link
|
55
61
|
# @option options @see Hyperlink#initialize All options available to the Hyperlink class apply - however href will be overridden with the v parameter value.
|
56
62
|
def hyperlink=(v, options={})
|
57
63
|
options[:href] = v
|
58
|
-
if
|
64
|
+
if hyperlink.is_a?(Hyperlink)
|
59
65
|
options.each do |o|
|
60
|
-
|
66
|
+
hyperlink.send("#{o[0]}=", o[1]) if hyperlink.respond_to? "#{o[0]}="
|
61
67
|
end
|
62
68
|
else
|
63
69
|
@hyperlink = Hyperlink.new(self, options)
|
64
70
|
end
|
65
|
-
|
71
|
+
hyperlink
|
66
72
|
end
|
67
73
|
|
68
74
|
def image_src=(v)
|
69
75
|
Axlsx::validate_string(v)
|
70
|
-
RestrictionValidator.validate 'Pic.image_src',
|
76
|
+
RestrictionValidator.validate 'Pic.image_src', ALLOWED_MIME_TYPES, MimeTypeUtils.get_mime_type(v)
|
71
77
|
raise ArgumentError, "File does not exist" unless File.exist?(v)
|
72
78
|
@image_src = v
|
73
79
|
end
|
@@ -78,7 +84,6 @@ module Axlsx
|
|
78
84
|
# @see descr
|
79
85
|
def descr=(v) Axlsx::validate_string(v); @descr = v; end
|
80
86
|
|
81
|
-
|
82
87
|
# The file name of image_src without any path information
|
83
88
|
# @return [String]
|
84
89
|
def file_name
|
@@ -110,7 +115,6 @@ module Axlsx
|
|
110
115
|
end
|
111
116
|
|
112
117
|
# providing access to the anchor's width attribute
|
113
|
-
# @param [Integer] v
|
114
118
|
# @see OneCellAnchor.width
|
115
119
|
def width
|
116
120
|
return unless @anchor.is_a?(OneCellAnchor)
|
@@ -124,7 +128,6 @@ module Axlsx
|
|
124
128
|
end
|
125
129
|
|
126
130
|
# providing access to update the anchor's height attribute
|
127
|
-
# @param [Integer] v
|
128
131
|
# @see OneCellAnchor.width
|
129
132
|
# @note this is a noop if you are using a TwoCellAnchor
|
130
133
|
def height
|
@@ -166,12 +169,16 @@ module Axlsx
|
|
166
169
|
str << '<xdr:pic>'
|
167
170
|
str << '<xdr:nvPicPr>'
|
168
171
|
str << ('<xdr:cNvPr id="2" name="' << name.to_s << '" descr="' << descr.to_s << '">')
|
169
|
-
|
172
|
+
hyperlink.to_xml_string(str) if hyperlink.is_a?(Hyperlink)
|
170
173
|
str << '</xdr:cNvPr><xdr:cNvPicPr>'
|
171
174
|
picture_locking.to_xml_string(str)
|
172
175
|
str << '</xdr:cNvPicPr></xdr:nvPicPr>'
|
173
176
|
str << '<xdr:blipFill>'
|
174
|
-
str << ('<a:blip xmlns:r ="' << XML_NS_R << '" r:embed="' << relationship.Id << '"
|
177
|
+
str << ('<a:blip xmlns:r ="' << XML_NS_R << '" r:embed="' << relationship.Id << '">')
|
178
|
+
if opacity
|
179
|
+
str << "<a:alphaModFix amt=\"#{opacity}\"/>"
|
180
|
+
end
|
181
|
+
str << '</a:blip>'
|
175
182
|
str << '<a:stretch><a:fillRect/></a:stretch></xdr:blipFill><xdr:spPr>'
|
176
183
|
str << '<a:xfrm><a:off x="0" y="0"/><a:ext cx="2336800" cy="2161540"/></a:xfrm>'
|
177
184
|
str << '<a:prstGeom prst="rect"><a:avLst/></a:prstGeom></xdr:spPr></xdr:pic>'
|
@@ -6,7 +6,7 @@ module Axlsx
|
|
6
6
|
include Axlsx::OptionsParser
|
7
7
|
|
8
8
|
# creates a new Scaling object
|
9
|
-
# @option options [Integer
|
9
|
+
# @option options [Integer] logBase
|
10
10
|
# @option options [Symbol] orientation
|
11
11
|
# @option options [Float] max
|
12
12
|
# @option options [Float] min
|
@@ -35,7 +35,7 @@ module Axlsx
|
|
35
35
|
attr_reader :min
|
36
36
|
|
37
37
|
# @see logBase
|
38
|
-
def logBase=(v) DataTypeValidator.validate "Scaling.logBase", [Integer
|
38
|
+
def logBase=(v) DataTypeValidator.validate "Scaling.logBase", [Integer], v, lambda { |arg| arg >= 2 && arg <= 1000}; @logBase = v; end
|
39
39
|
# @see orientation
|
40
40
|
def orientation=(v) RestrictionValidator.validate "Scaling.orientation", [:minMax, :maxMin], v; @orientation = v; end
|
41
41
|
# @see max
|
@@ -21,10 +21,13 @@ module Axlsx
|
|
21
21
|
# @return [String]
|
22
22
|
attr_reader :color
|
23
23
|
|
24
|
+
# @return [String]
|
25
|
+
attr_reader :ln_width
|
26
|
+
|
24
27
|
# Line smoothing between data points
|
25
28
|
# @return [Boolean]
|
26
29
|
attr_reader :smooth
|
27
|
-
|
30
|
+
|
28
31
|
# Creates a new ScatterSeries
|
29
32
|
def initialize(chart, options={})
|
30
33
|
@xData, @yData = nil
|
@@ -36,6 +39,7 @@ module Axlsx
|
|
36
39
|
Axlsx::validate_boolean(options[:smooth])
|
37
40
|
@smooth = options[:smooth]
|
38
41
|
end
|
42
|
+
@ln_width = options[:ln_width] unless options[:ln_width].nil?
|
39
43
|
super(chart, options)
|
40
44
|
@xData = AxDataSource.new(:tag_name => :xVal, :data => options[:xData]) unless options[:xData].nil?
|
41
45
|
@yData = NumDataSource.new({:tag_name => :yVal, :data => options[:yData]}) unless options[:yData].nil?
|
@@ -51,7 +55,12 @@ module Axlsx
|
|
51
55
|
Axlsx::validate_boolean(v)
|
52
56
|
@smooth = v
|
53
57
|
end
|
54
|
-
|
58
|
+
|
59
|
+
# @see ln_width
|
60
|
+
def ln_width=(v)
|
61
|
+
@ln_width = v
|
62
|
+
end
|
63
|
+
|
55
64
|
# Serializes the object
|
56
65
|
# @param [String] str
|
57
66
|
# @return [String]
|
@@ -74,6 +83,11 @@ module Axlsx
|
|
74
83
|
str << '</c:spPr>'
|
75
84
|
str << '</c:marker>'
|
76
85
|
end
|
86
|
+
if ln_width
|
87
|
+
str << '<c:spPr>'
|
88
|
+
str << '<a:ln w="' << ln_width.to_s << '"/>'
|
89
|
+
str << '</c:spPr>'
|
90
|
+
end
|
77
91
|
@xData.to_xml_string(str) unless @xData.nil?
|
78
92
|
@yData.to_xml_string(str) unless @yData.nil?
|
79
93
|
str << ('<c:smooth val="' << ((smooth) ? '1' : '0') << '"/>')
|
@@ -26,7 +26,9 @@ module Axlsx
|
|
26
26
|
# serialize the object
|
27
27
|
def to_xml_string(idx, str = "")
|
28
28
|
Axlsx::validate_unsigned_int(idx)
|
29
|
-
|
29
|
+
if !v.to_s.empty?
|
30
|
+
str << ('<c:pt idx="' << idx.to_s << '"><c:v>' << ::CGI.escapeHTML(v.to_s) << '</c:v></c:pt>')
|
31
|
+
end
|
30
32
|
end
|
31
33
|
end
|
32
34
|
end
|
data/lib/axlsx/drawing/title.rb
CHANGED
@@ -7,15 +7,24 @@ module Axlsx
|
|
7
7
|
# @return [String]
|
8
8
|
attr_reader :text
|
9
9
|
|
10
|
+
# Text size property
|
11
|
+
# @return [String]
|
12
|
+
attr_reader :text_size
|
13
|
+
|
10
14
|
# The cell that holds the text for the title. Setting this property will automatically update the text attribute.
|
11
15
|
# @return [Cell]
|
12
16
|
attr_reader :cell
|
13
17
|
|
14
18
|
# Creates a new Title object
|
15
19
|
# @param [String, Cell] title The cell or string to be used for the chart's title
|
16
|
-
def initialize(title="")
|
20
|
+
def initialize(title="", title_size="")
|
17
21
|
self.cell = title if title.is_a?(Cell)
|
18
22
|
self.text = title.to_s unless title.is_a?(Cell)
|
23
|
+
if title_size.to_s.empty?
|
24
|
+
self.text_size = "1600"
|
25
|
+
else
|
26
|
+
self.text_size = title_size.to_s
|
27
|
+
end
|
19
28
|
end
|
20
29
|
|
21
30
|
# @see text
|
@@ -26,6 +35,14 @@ module Axlsx
|
|
26
35
|
v
|
27
36
|
end
|
28
37
|
|
38
|
+
# @see text_size
|
39
|
+
def text_size=(v)
|
40
|
+
DataTypeValidator.validate 'Title.text_size', String, v
|
41
|
+
@text_size = v
|
42
|
+
@cell = nil
|
43
|
+
v
|
44
|
+
end
|
45
|
+
|
29
46
|
# @see cell
|
30
47
|
def cell=(v)
|
31
48
|
DataTypeValidator.validate 'Title.text', Cell, v
|
@@ -62,6 +79,7 @@ module Axlsx
|
|
62
79
|
str << '<a:lstStyle/>'
|
63
80
|
str << '<a:p>'
|
64
81
|
str << '<a:r>'
|
82
|
+
str << ('<a:rPr sz="' << @text_size.to_s << '"/>')
|
65
83
|
str << ('<a:t>' << @text.to_s << '</a:t>')
|
66
84
|
str << '</a:r>'
|
67
85
|
str << '</a:p>'
|
@@ -37,11 +37,16 @@ module Axlsx
|
|
37
37
|
drawing.anchors << self
|
38
38
|
@from, @to = Marker.new, Marker.new(:col => 5, :row=>10)
|
39
39
|
parse_options options
|
40
|
+
|
41
|
+
# bit of a hack to work around the fact that the coords for start at and end at
|
42
|
+
# are passed in as an array when specified in intialization options - however
|
43
|
+
start_at(*options[:start_at]) if options[:start_at]
|
44
|
+
end_at(*options[:end_at]) if options[:end_at]
|
40
45
|
end
|
41
46
|
|
42
47
|
# sets the col, row attributes for the from marker.
|
43
48
|
# @note The recommended way to set the start position for graphical
|
44
|
-
# objects is directly thru the object.
|
49
|
+
# objects is directly thru the object.
|
45
50
|
# @see Chart#start_at
|
46
51
|
def start_at(x, y=nil)
|
47
52
|
from.coord x, y
|
@@ -86,12 +86,12 @@ module Axlsx
|
|
86
86
|
alias :rAngAx= :r_ang_ax=
|
87
87
|
|
88
88
|
# @see perspective
|
89
|
-
def perspective=(v)
|
89
|
+
def perspective=(v)
|
90
90
|
RangeValidator.validate "View3D.perspective", 0, 240, v
|
91
91
|
@perspective = v
|
92
92
|
end
|
93
93
|
|
94
|
-
# DataTypeValidator.validate "#{self.class}.perspective", [Integer
|
94
|
+
# DataTypeValidator.validate "#{self.class}.perspective", [Integer], v, lambda {|arg| arg >= 0 && arg <= 240 }; @perspective = v; end
|
95
95
|
|
96
96
|
# Serializes the object
|
97
97
|
# @param [String] str
|
data/lib/axlsx/package.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# encoding:
|
1
|
+
# encoding: utf-8
|
2
2
|
module Axlsx
|
3
3
|
# Package is responsible for managing all the bits and peices that Open Office XML requires to make a valid
|
4
4
|
# xlsx document including valdation and serialization.
|
@@ -147,11 +147,7 @@ module Axlsx
|
|
147
147
|
errors = []
|
148
148
|
parts.each do |part|
|
149
149
|
unless part[:schema].nil?
|
150
|
-
|
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
|
150
|
+
errors.concat validate_single_doc(part[:schema], part[:doc].to_xml_string)
|
155
151
|
end
|
156
152
|
end
|
157
153
|
errors
|
@@ -165,20 +161,13 @@ module Axlsx
|
|
165
161
|
def write_parts(zip)
|
166
162
|
p = parts
|
167
163
|
p.each do |part|
|
168
|
-
#next unless part[:entry] == CORE_PN
|
169
164
|
unless part[:doc].nil?
|
170
165
|
zip.put_next_entry(zip_entry_for_part(part))
|
171
|
-
|
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
|
+
part[:doc].to_xml_string(zip)
|
177
167
|
end
|
178
168
|
unless part[:path].nil?
|
179
169
|
zip.put_next_entry(zip_entry_for_part(part))
|
180
|
-
|
181
|
-
zip.write IO.respond_to?(:binread) ? IO.binread(part[:path]) : IO.read(part[:path])
|
170
|
+
zip.write IO.read(part[:path])
|
182
171
|
end
|
183
172
|
end
|
184
173
|
zip
|
@@ -253,7 +242,9 @@ module Axlsx
|
|
253
242
|
parts << {:entry => "xl/#{sheet.rels_pn}", :doc => sheet.relationships, :schema => RELS_XSD}
|
254
243
|
parts << {:entry => "xl/#{sheet.pn}", :doc => sheet, :schema => SML_XSD}
|
255
244
|
end
|
256
|
-
|
245
|
+
|
246
|
+
# Sort parts for correct MIME detection
|
247
|
+
parts.sort_by { |part| part[:entry] }
|
257
248
|
end
|
258
249
|
|
259
250
|
# Performs xsd validation for a signle document
|