lib/axlsx/workbook/workbook.rb in axlsx-2.1.0.pre vs lib/axlsx/workbook/workbook.rb in axlsx-3.0.0.pre
- old
+ new
@@ -9,10 +9,11 @@
require 'axlsx/workbook/worksheet/rich_text'
require 'axlsx/workbook/worksheet/cell_serializer.rb'
require 'axlsx/workbook/worksheet/cell.rb'
require 'axlsx/workbook/worksheet/page_margins.rb'
require 'axlsx/workbook/worksheet/page_set_up_pr.rb'
+require 'axlsx/workbook/worksheet/outline_pr.rb'
require 'axlsx/workbook/worksheet/page_setup.rb'
require 'axlsx/workbook/worksheet/header_footer.rb'
require 'axlsx/workbook/worksheet/print_options.rb'
require 'axlsx/workbook/worksheet/cfvo.rb'
require 'axlsx/workbook/worksheet/cfvos.rb'
@@ -94,11 +95,20 @@
def use_shared_strings=(v)
Axlsx::validate_boolean(v)
@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
# @see Workbook#add_worksheet
# @see Worksheet
# @return [SimpleTypedList]
@@ -268,10 +278,14 @@
worksheet = Worksheet.new(self, options)
yield worksheet if block_given?
worksheet
end
+ # Adds a new WorkbookView
+ # @return WorkbookViews
+ # @option options [Hash] options passed into the added WorkbookView
+ # @see WorkbookView#initialize
def add_view(options={})
views << WorkbookView.new(options)
end
# Adds a defined name to this workbook
@@ -342,10 +356,14 @@
str << '<?xml version="1.0" encoding="UTF-8"?>'
str << ('<workbook xmlns="' << XML_NS << '" xmlns:r="' << XML_NS_R << '">')
str << ('<workbookPr date1904="' << @@date1904.to_s << '"/>')
views.to_xml_string(str)
str << '<sheets>'
- 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 << '</sheets>'
defined_names.to_xml_string(str)
unless pivot_tables.empty?
str << '<pivotCaches>'
pivot_tables.each do |pivot_table|