summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--lib/axlsx/workbook/worksheet/sheet_pr.rb63
1 files changed, 6 insertions, 57 deletions
diff --git a/lib/axlsx/workbook/worksheet/sheet_pr.rb b/lib/axlsx/workbook/worksheet/sheet_pr.rb
index a13c906e..337d7272 100644
--- a/lib/axlsx/workbook/worksheet/sheet_pr.rb
+++ b/lib/axlsx/workbook/worksheet/sheet_pr.rb
@@ -1,28 +1,11 @@
module Axlsx
- #<xsd:complexType name="CT_SheetPr">
- #<xsd:sequence>
- #<xsd:element name="tabColor" type="CT_Color" minOccurs="0" maxOccurs="1"/>
- #<xsd:element name="outlinePr" type="CT_OutlinePr" minOccurs="0" maxOccurs="1"/>
- #<xsd:element name="pageSetUpPr" type="CT_PageSetUpPr" minOccurs="0" maxOccurs="1"/>
- #</xsd:sequence>
- #<xsd:attribute name="syncHorizontal" type="xsd:boolean" use="optional" default="false"/>
- #<xsd:attribute name="syncVertical" type="xsd:boolean" use="optional" default="false"/>
- #<xsd:attribute name="syncRef" type="ST_Ref" use="optional"/>
- #<xsd:attribute name="transitionEvaluation" type="xsd:boolean" use="optional" default="false"/>
- #<xsd:attribute name="transitionEntry" type="xsd:boolean" use="optional" default="false"/>
- #<xsd:attribute name="published" type="xsd:boolean" use="optional" default="true"/>
- #<xsd:attribute name="codeName" type="xsd:string" use="optional"/>
- #<xsd:attribute name="filterMode" type="xsd:boolean" use="optional" default="false"/>
- #<xsd:attribute name="enableFormatConditionsCalculation" type="xsd:boolean" use="optional" default="true"/>
- #</xsd:complexType>
+
# The SheetPr class manages serialization fo a worksheet's sheetPr element.
- # Only fit_to_page is implemented
class SheetPr
# These attributes are all boolean so I'm doing a bit of a hand
# waving magic show to set up the attriubte accessors
- #
BOOLEAN_ATTRIBUTES = [:sync_horizontal,
:sync_vertical,
:transtion_evaluation,
@@ -34,9 +17,13 @@ module Axlsx
# Creates a new SheetPr object
# @param [Worksheet] worksheet The worksheet that owns this SheetPr object
- def initialize(worksheet)
+ def initialize(worksheet, options={})
raise ArgumentError, "you must provide a worksheet" unless worksheet.is_a?(Worksheet)
@worksheet = worksheet
+ options.each do |key, value|
+ attr = "#{key}="
+ self.send(attr, value) if self.respond_to?(attr)
+ end
end
# Dynamically create accessors for boolean attriubtes
@@ -107,7 +94,6 @@ module Axlsx
str
end
-
def update_properties
page_setup_pr.fit_to_page = worksheet.fit_to_page?
if worksheet.auto_filter.columns.size > 0
@@ -116,41 +102,4 @@ module Axlsx
end
end
end
-
-
- class PageSetUpPr
-
- # creates a new page setup properties object
- # @param [Hash] options
- # @option [Boolean] fit_to_page Flag indicating whether the sheet displays Automatic Page Breaks.
- # @option [Boolean] auto_page_breaks Flag indicating whether the Fit to Page print option is enabled.
- def initialize(options = {})
- options.each do |key, value|
- self.send("#{key}=",value) if self.respond_to?("#{key}=")
- end
- end
-
- # Flag indicating whether the sheet displays Automatic Page Breaks.
- # @param [Boolean] value
- # @return [Boolean]
- def fit_to_page=(value)
- Axlsx.validate_boolean value
- @fit_to_page = value
- end
-
- # Flag indicating whether the Fit to Page print option is enabled.
- # @param [Boolean] value
- # @return [Boolean]
- def auto_page_breaks=(value)
- Alxsx.validate_boolean value
- @auto_page_breaks = value
- end
-
- # serialize to xml
- def to_xml_string(str='')
- str << '<pageSetUpPr '
- instance_values.each { |key, value| str << "#{Axlsx.camel(key, false)}='#{value}' " }
- str << '></pageSetUpPr>'
- end
- end
end