summaryrefslogtreecommitdiffhomepage
path: root/lib
diff options
context:
space:
mode:
authorRandy Morgan <[email protected]>2012-05-16 20:10:19 +0900
committerRandy Morgan <[email protected]>2012-05-16 20:10:19 +0900
commit2c8d79816ef12b2b90211aafdd78bc141220f161 (patch)
tree87b0443a6d606b3db4542b406d3e4d7a90c8b503 /lib
parent2d6ca8e719a158aae83797b6d6f601486d90d48d (diff)
downloadcaxlsx-2c8d79816ef12b2b90211aafdd78bc141220f161.tar.gz
caxlsx-2c8d79816ef12b2b90211aafdd78bc141220f161.zip
depreciating Worksheet.fit_to_page as a writable attribute.
Diffstat (limited to 'lib')
-rw-r--r--lib/axlsx/workbook/worksheet/page_setup.rb17
-rw-r--r--lib/axlsx/workbook/worksheet/table.rb4
-rw-r--r--lib/axlsx/workbook/worksheet/worksheet.rb16
3 files changed, 17 insertions, 20 deletions
diff --git a/lib/axlsx/workbook/worksheet/page_setup.rb b/lib/axlsx/workbook/worksheet/page_setup.rb
index 83195b62..af5f2411 100644
--- a/lib/axlsx/workbook/worksheet/page_setup.rb
+++ b/lib/axlsx/workbook/worksheet/page_setup.rb
@@ -45,12 +45,7 @@ module Axlsx
# @return [Integer]
attr_reader :scale
- # The worksheet that owns this page_setup.
- # @return [Worksheet]
- attr_reader :worksheet
-
# Creates a new PageSetup object
- # @option options [Worksheet] worksheet The worksheet that owns this page_setup **required**
# @option options [Integer] fit_to_height Number of vertical pages to fit on
# @option options [Integer] fit_to_width Number of horizontal pages to fit on
# @option options [Symbol] orientation Orientation of the page (:default, :landscape, :portrait)
@@ -58,8 +53,6 @@ module Axlsx
# @option options [String] paper_width Width of paper (number followed by unit identifier: "210mm", "8.5in")
# @option options [Integer] scale Print scaling (percent value, integer ranging from 10 to 400)
def initialize(options = {})
- raise ArgumentError, "Worksheet option is required" unless options[:worksheet].is_a?(Worksheet)
- @worksheet = options[:worksheet]
set(options)
end
@@ -72,15 +65,15 @@ module Axlsx
end
# @see fit_to_height
- def fit_to_height=(v); Axlsx::validate_unsigned_int(v); @fit_to_height = v; @worksheet.fit_to_page = (@fit_to_height.to_i + @fit_to_width.to_i > 0); end
+ def fit_to_height=(v); Axlsx::validate_unsigned_int(v); @fit_to_height = v end
# @see fit_to_width
- def fit_to_width=(v); Axlsx::validate_unsigned_int(v); @fit_to_width = v; @worksheet.fit_to_page = (@fit_to_height.to_i + @fit_to_width.to_i > 0); end
+ def fit_to_width=(v); Axlsx::validate_unsigned_int(v); @fit_to_width = v end
# @see orientation
- def orientation=(v); Axlsx::validate_page_orientation(v); @orientation = v; end
+ def orientation=(v); Axlsx::validate_page_orientation(v); @orientation = v end
# @see paper_height
- def paper_height=(v); Axlsx::validate_number_with_unit(v); @paper_height = v; end
+ def paper_height=(v); Axlsx::validate_number_with_unit(v); @paper_height = v end
# @see paper_width
- def paper_width=(v); Axlsx::validate_number_with_unit(v); @paper_width = v; end
+ def paper_width=(v); Axlsx::validate_number_with_unit(v); @paper_width = v end
# @see scale
def scale=(v); Axlsx::validate_page_scale(v); @scale = v; end
diff --git a/lib/axlsx/workbook/worksheet/table.rb b/lib/axlsx/workbook/worksheet/table.rb
index 1ed23cc5..b848180b 100644
--- a/lib/axlsx/workbook/worksheet/table.rb
+++ b/lib/axlsx/workbook/worksheet/table.rb
@@ -19,8 +19,8 @@ module Axlsx
attr_reader :style
# Creates a new Table object
- # @param [String] ref The reference to the table data.
- # @param [Sheet] ref The sheet containing the table data.
+ # @param [String] ref The reference to the table data like 'A1:G24'.
+ # @param [Worksheet] sheet The sheet containing the table data.
# @option options [Cell, String] name
# @option options [TableStyle] style
def initialize(ref, sheet, options={})
diff --git a/lib/axlsx/workbook/worksheet/worksheet.rb b/lib/axlsx/workbook/worksheet/worksheet.rb
index 3789ba60..854e629c 100644
--- a/lib/axlsx/workbook/worksheet/worksheet.rb
+++ b/lib/axlsx/workbook/worksheet/worksheet.rb
@@ -51,10 +51,14 @@ module Axlsx
# @return Boolean
attr_reader :selected
- # Indicates if the worksheet should be fitted to a single page when printed. If you want the worksheet to fit on more pages (e.g. 2x2), set {PageSetup#fit_to_width} and {PageSetup#fit_to_height} accordingly.
+ # Indicates if the worksheet will be fit by witdh or height to a specific number of pages.
+ # To alter the width or height for page fitting, please use page_setup.fit_to_widht or page_setup.fit_to_height.
+ # If you want the worksheet to fit on more pages (e.g. 2x2), set {PageSetup#fit_to_width} and {PageSetup#fit_to_height} accordingly.
# @return Boolean
# @see #page_setup
- attr_reader :fit_to_page
+ def fit_to_page
+ (@page_setup != nil && (@page_setup.fit_to_width != nil || @page_setup.fit_to_height != nil))
+ end
# Column info for the sheet
@@ -102,7 +106,7 @@ module Axlsx
# @see PageSetup#initialize
# @return [PageSetup]
def page_setup
- @page_setup ||= PageSetup.new(:worksheet => self)
+ @page_setup ||= PageSetup.new
yield @page_setup if block_given?
@page_setup
end
@@ -156,7 +160,7 @@ module Axlsx
@show_gridlines = true
self.name = "Sheet" + (index+1).to_s
@page_margins = PageMargins.new options[:page_margins] if options[:page_margins]
- @page_setup = PageSetup.new options[:page_setup].merge(:worksheet=>self) if options[:page_setup]
+ @page_setup = PageSetup.new options[:page_setup] if options[:page_setup]
@print_options = PrintOptions.new options[:print_options] if options[:print_options]
@rows = SimpleTypedList.new Row
@column_info = SimpleTypedList.new Col
@@ -237,8 +241,8 @@ module Axlsx
# (see #fit_to_page)
# @return [Boolean]
def fit_to_page=(v)
- Axlsx::validate_boolean v
- @fit_to_page = v
+ warn('DEPRECIATED: fit_to_page has been depreciated. This value will automatically be set for you when page_setup.fit_to_width or page_setup.fit_to_height are specified.')
+ fit_to_page
end