diff options
| author | Erik Veijola <[email protected]> | 2015-07-28 15:18:09 +0300 |
|---|---|---|
| committer | Erik Veijola <[email protected]> | 2015-07-29 10:57:51 +0300 |
| commit | 2b19dba7cc8f19f47594b90ea9fb7888678b0224 (patch) | |
| tree | 25caad585b6efffb4afb687d03f10e93dc9e90b3 /lib/axlsx/workbook/workbook.rb | |
| parent | 78bfed8f5ab1de0096174795635cd41dc1bea43a (diff) | |
| download | caxlsx-2b19dba7cc8f19f47594b90ea9fb7888678b0224.tar.gz caxlsx-2b19dba7cc8f19f47594b90ea9fb7888678b0224.zip | |
workbook.rb: added possibility to reverse the serialization order of workbook
Signed-off-by: Erik Veijola <[email protected]>
Diffstat (limited to 'lib/axlsx/workbook/workbook.rb')
| -rw-r--r-- | lib/axlsx/workbook/workbook.rb | 15 |
1 files changed, 14 insertions, 1 deletions
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 << ('<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? |
