summaryrefslogtreecommitdiffhomepage
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/axlsx/drawing/d_lbls.rb18
-rw-r--r--lib/axlsx/drawing/pie_3D_chart.rb3
-rw-r--r--lib/axlsx/drawing/scatter_chart.rb12
-rw-r--r--lib/axlsx/workbook/defined_name.rb20
-rw-r--r--lib/axlsx/workbook/worksheet/auto_filter.rb6
5 files changed, 26 insertions, 33 deletions
diff --git a/lib/axlsx/drawing/d_lbls.rb b/lib/axlsx/drawing/d_lbls.rb
index eb4bfea5..54f054fb 100644
--- a/lib/axlsx/drawing/d_lbls.rb
+++ b/lib/axlsx/drawing/d_lbls.rb
@@ -2,19 +2,9 @@ module Axlsx
# There are more elements in the dLbls spec that allow for
# customizations and formatting. For now, I am just implementing the
# basics.
- #
- #<c:dLbls>
- #<c:dLblPos val="outEnd"/>
- #<c:showLegendKey val="0"/>
- #<c:showVal val="0"/>
- #<c:showCatName val="1"/>
- #<c:showSerName val="0"/>
- #<c:showPercent val="1"/>
- #<c:showBubbleSize val="0"/>
- #<c:showLeaderLines val="1"/>
- #</c:dLbls>
#The DLbls class manages serialization of data labels
+ # showLeaderLines and leaderLines are not currently implemented
class DLbls
# These attributes are all boolean so I'm doing a bit of a hand
@@ -91,9 +81,9 @@ module Axlsx
def to_xml_string(str = '')
validate_attributes_for_chart_type
str << '<c:dLbls>'
- instance_values.each do |key, value|
- next if key == :formula
- str << "<c:#{Axlsx::camel(key, false)} val='#{value}' />"
+ %w(d_lbl_pos show_legend_key show_val show_cat_name show_ser_name show_percent show_bubble_size show_leader_lines).each do |key|
+ next unless instance_values.keys.include?(key) && instance_values[key] != nil
+ str << "<c:#{Axlsx::camel(key, false)} val='#{instance_values[key]}' />"
end
str << '</c:dLbls>'
end
diff --git a/lib/axlsx/drawing/pie_3D_chart.rb b/lib/axlsx/drawing/pie_3D_chart.rb
index 059d4148..da51d08b 100644
--- a/lib/axlsx/drawing/pie_3D_chart.rb
+++ b/lib/axlsx/drawing/pie_3D_chart.rb
@@ -34,10 +34,11 @@ module Axlsx
# @return [String]
def to_xml_string(str = '')
super(str) do |str_inner|
+
str_inner << '<c:pie3DChart>'
str_inner << '<c:varyColors val="1"/>'
@series.each { |ser| ser.to_xml_string(str_inner) }
- @d_lbls.to_xml_string(str) if @d_lbls
+ d_lbls.to_xml_string(str) if @d_lbls
str_inner << '</c:pie3DChart>'
end
end
diff --git a/lib/axlsx/drawing/scatter_chart.rb b/lib/axlsx/drawing/scatter_chart.rb
index b3cd8c29..92ef9cf2 100644
--- a/lib/axlsx/drawing/scatter_chart.rb
+++ b/lib/axlsx/drawing/scatter_chart.rb
@@ -50,17 +50,7 @@ module Axlsx
str_inner << '<c:scatterStyle val="' << scatterStyle.to_s << '"/>'
str_inner << '<c:varyColors val="1"/>'
@series.each { |ser| ser.to_xml_string(str_inner) }
- if @d_lbls
- @d_lbls.to_xml_string(str)
- end
- str_inner << '<c:dLbls>'
- str_inner << '<c:showLegendKey val="0"/>'
- str_inner << '<c:showVal val="0"/>'
- str_inner << '<c:showCatName val="0"/>'
- str_inner << '<c:showSerName val="0"/>'
- str_inner << '<c:showPercent val="0"/>'
- str_inner << '<c:showBubbleSize val="0"/>'
- str_inner << '</c:dLbls>'
+ d_lbls.to_xml_string(str) if @d_lbls
str_inner << '<c:axId val="' << @xValAxId.to_s << '"/>'
str_inner << '<c:axId val="' << @yValAxId.to_s << '"/>'
str_inner << '</c:scatterChart>'
diff --git a/lib/axlsx/workbook/defined_name.rb b/lib/axlsx/workbook/defined_name.rb
index da558956..ed4774e8 100644
--- a/lib/axlsx/workbook/defined_name.rb
+++ b/lib/axlsx/workbook/defined_name.rb
@@ -52,6 +52,7 @@ module Axlsx
# creates a new DefinedName.
# @param [String] formula - the formula the defined name references
# @param [Hash] options - A hash of key/value pairs that will be mapped to this instances attributes.
+ #
# @option [String] name - Specifies the name that appears in the user interface for the defined name.
# This attribute is required.
# The following built-in names are defined in this SpreadsheetML specification:
@@ -70,9 +71,9 @@ module Axlsx
# _xlnm.Extract: this defined name refers to the range containing the filtered output
# values resulting from applying an advanced filter criteria to a source range.
# Miscellaneous
- # _xlnm .Consolidate_Area: the defined name refers to a consolidation area.
- # _xlnm .Database: the range specified in the defined name is from a database data source.
- # _xlnm .Sheet_Title: the defined name refers to a sheet title.
+ # _xlnm.Consolidate_Area: the defined name refers to a consolidation area.
+ # _xlnm.Database: the range specified in the defined name is from a database data source.
+ # _xlnm.Sheet_Title: the defined name refers to a sheet title.
# @option [String] comment - A comment to optionally associate with the name
# @option [String] custom_menu - The menu text for the defined name
# @option [String] description - An optional description for the defined name
@@ -106,7 +107,7 @@ module Axlsx
@local_sheet_id = value
end
# string attributes that will be added when this class is evaluated
- STRING_ATTRIBUTES = [:short_cut_key, :status_bar, :help, :description, :custom_menu, :comment, :name]
+ STRING_ATTRIBUTES = [:short_cut_key, :status_bar, :help, :description, :custom_menu, :comment]
# boolean attributes that will be added when this class is evaluated
BOOLEAN_ATTRIBUTES = [:workbook_parameter, :publish_to_server, :xlm, :vb_proceedure, :function, :hidden]
@@ -144,8 +145,19 @@ module Axlsx
end
}
end
+
+ attr_reader :name
+ # The name of this defined name. Please refer to the class documentation for more information
+ def name=(value)
+ Axlsx::RestrictionValidator.validate 'DefinedName.name', %w(_xlnm.Print_Area _xlnm.Print_Titles _xlnm.Criteria _xlnm._FilterDatabase _xlnm.Extract _xlnm.Consolidate_Area _xlnm.Database _xlnm.Sheet_Title), value
+ @name = value
+ end
+
+ # The formula this defined name references
+ attr_reader :formula
def to_xml_string(str='')
+ raise ArgumentError, 'you must specify the name for this defined name. Please read the documentation for Axlsx::DefinedName for more details' unless name
str << '<definedName'
instance_values.each do |name, value|
unless name == 'formula'
diff --git a/lib/axlsx/workbook/worksheet/auto_filter.rb b/lib/axlsx/workbook/worksheet/auto_filter.rb
index 10873119..f2197c37 100644
--- a/lib/axlsx/workbook/worksheet/auto_filter.rb
+++ b/lib/axlsx/workbook/worksheet/auto_filter.rb
@@ -6,18 +6,18 @@ module Axlsx
raise ArgumentError, 'you must provide a worksheet' unless worksheet.is_a?(Worksheet)
@worksheet = worksheet
end
-
+
attr_reader :worksheet
attr_accessor :range
def defined_name
return unless range
Axlsx.cell_range(range.split(':').collect { |name| worksheet.name_to_cell(name)})
- end
+ end
def to_xml_string(str='')
str << "<autoFilter ref='#{range}'></autoFilter>"
end
-
+
end
end