From aa11b0c7de15b286246e943a7d2fb962e12bde83 Mon Sep 17 00:00:00 2001 From: Erik Veijola Date: Tue, 28 Jul 2015 11:38:45 +0300 Subject: title.rb: added text_size to set the font size of the title Signed-off-by: Erik Veijola --- lib/axlsx/drawing/title.rb | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/axlsx/drawing/title.rb b/lib/axlsx/drawing/title.rb index 4e278689..7f2ff9f4 100644 --- a/lib/axlsx/drawing/title.rb +++ b/lib/axlsx/drawing/title.rb @@ -7,15 +7,24 @@ module Axlsx # @return [String] attr_reader :text + # Text size property + # @return [String] + attr_reader :text_size + # The cell that holds the text for the title. Setting this property will automatically update the text attribute. # @return [Cell] attr_reader :cell # Creates a new Title object # @param [String, Cell] title The cell or string to be used for the chart's title - def initialize(title="") + def initialize(title="", title_size="") self.cell = title if title.is_a?(Cell) self.text = title.to_s unless title.is_a?(Cell) + if title_size.to_s.empty? + self.text_size = "1600" + else + self.text_size = title_size.to_s + end end # @see text @@ -26,6 +35,14 @@ module Axlsx v end + # @see text_size + def text_size=(v) + DataTypeValidator.validate 'Title.text_size', String, v + @text_size = v + @cell = nil + v + end + # @see cell def cell=(v) DataTypeValidator.validate 'Title.text', Cell, v @@ -62,6 +79,7 @@ module Axlsx str << '' str << '' str << '' + str << ('') str << ('' << @text.to_s << '') str << '' str << '' -- cgit v1.2.3 From 137dc0d94bd771893b88e22628331786cb0c56df Mon Sep 17 00:00:00 2001 From: Erik Veijola Date: Tue, 28 Jul 2015 11:45:21 +0300 Subject: chart.rb: added method to set font size of Title object in chart Signed-off-by: Erik Veijola --- lib/axlsx/drawing/chart.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lib') diff --git a/lib/axlsx/drawing/chart.rb b/lib/axlsx/drawing/chart.rb index e7fcc9e8..de87b91a 100644 --- a/lib/axlsx/drawing/chart.rb +++ b/lib/axlsx/drawing/chart.rb @@ -128,6 +128,11 @@ module Axlsx end end + # The size of the Title object of the chart. + def title_size=(v) + @title.text_size = v unless v.to_s.empty? + end + # Show the legend in the chart # @param [Boolean] v # @return [Boolean] -- cgit v1.2.3 From 18bfcd27f6ded316c28b6029911c1bdd231319ed Mon Sep 17 00:00:00 2001 From: Erik Veijola Date: Tue, 28 Jul 2015 15:10:37 +0300 Subject: scatter_series.rb: added line_width to scatter series Signed-off-by: Erik Veijola --- lib/axlsx/drawing/scatter_series.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'lib') diff --git a/lib/axlsx/drawing/scatter_series.rb b/lib/axlsx/drawing/scatter_series.rb index c0d6e8f1..6b71227c 100644 --- a/lib/axlsx/drawing/scatter_series.rb +++ b/lib/axlsx/drawing/scatter_series.rb @@ -21,6 +21,9 @@ module Axlsx # @return [String] attr_reader :color + # @return [String] + attr_reader :ln_width + # Line smoothing between data points # @return [Boolean] attr_reader :smooth @@ -36,6 +39,7 @@ module Axlsx Axlsx::validate_boolean(options[:smooth]) @smooth = options[:smooth] end + @ln_width = options[:ln_width] unless options[:ln_width].nil? super(chart, options) @xData = AxDataSource.new(:tag_name => :xVal, :data => options[:xData]) unless options[:xData].nil? @yData = NumDataSource.new({:tag_name => :yVal, :data => options[:yData]}) unless options[:yData].nil? @@ -52,6 +56,11 @@ module Axlsx @smooth = v end + # @see ln_width + def ln_width=(v) + @ln_width = v + end + # Serializes the object # @param [String] str # @return [String] @@ -74,6 +83,11 @@ module Axlsx str << '' str << '' end + if ln_width + str << '' + str << '' + str << '' + end @xData.to_xml_string(str) unless @xData.nil? @yData.to_xml_string(str) unless @yData.nil? str << ('') -- cgit v1.2.3 From 78bfed8f5ab1de0096174795635cd41dc1bea43a Mon Sep 17 00:00:00 2001 From: Erik Veijola Date: Tue, 28 Jul 2015 15:15:43 +0300 Subject: num_val.rb, str_val.rb: added checking for nil values in to_xml_string Signed-off-by: Erik Veijola --- lib/axlsx/drawing/num_val.rb | 4 +++- lib/axlsx/drawing/str_val.rb | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/axlsx/drawing/num_val.rb b/lib/axlsx/drawing/num_val.rb index bd733cb7..b430c4b6 100644 --- a/lib/axlsx/drawing/num_val.rb +++ b/lib/axlsx/drawing/num_val.rb @@ -26,7 +26,9 @@ module Axlsx # serialize the object def to_xml_string(idx, str = "") Axlsx::validate_unsigned_int(idx) - str << ('' << v.to_s << '') + if !v.to_s.empty? + str << ('' << v.to_s << '') + end end end end diff --git a/lib/axlsx/drawing/str_val.rb b/lib/axlsx/drawing/str_val.rb index b0692784..10a4fe91 100644 --- a/lib/axlsx/drawing/str_val.rb +++ b/lib/axlsx/drawing/str_val.rb @@ -26,7 +26,9 @@ module Axlsx # serialize the object def to_xml_string(idx, str = "") Axlsx::validate_unsigned_int(idx) - str << ('' << v.to_s << '') + if !v.to_s.empty? + str << ('' << v.to_s << '') + end end end end -- cgit v1.2.3 From 2b19dba7cc8f19f47594b90ea9fb7888678b0224 Mon Sep 17 00:00:00 2001 From: Erik Veijola Date: Tue, 28 Jul 2015 15:18:09 +0300 Subject: workbook.rb: added possibility to reverse the serialization order of workbook Signed-off-by: Erik Veijola --- lib/axlsx/workbook/workbook.rb | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/axlsx/workbook/workbook.rb b/lib/axlsx/workbook/workbook.rb index 784ee0b4..ddb13600 100644 --- a/lib/axlsx/workbook/workbook.rb +++ b/lib/axlsx/workbook/workbook.rb @@ -96,6 +96,15 @@ require 'axlsx/workbook/worksheet/selection.rb' @use_shared_strings = v end + # If true reverse the order in which the workbook is serialized + # @return [Boolean] + attr_reader :is_reversed + + def is_reversed=(v) + Axlsx::validate_boolean(v) + @is_reversed = v + end + # A collection of worksheets associated with this workbook. # @note The recommended way to manage worksheets is add_worksheet @@ -344,7 +353,11 @@ require 'axlsx/workbook/worksheet/selection.rb' str << ('') views.to_xml_string(str) str << '' - worksheets.each { |sheet| sheet.to_sheet_node_xml_string(str) } + if is_reversed + worksheets.reverse_each { |sheet| sheet.to_sheet_node_xml_string(str) } + else + worksheets.each { |sheet| sheet.to_sheet_node_xml_string(str) } + end str << '' defined_names.to_xml_string(str) unless pivot_tables.empty? -- cgit v1.2.3