summaryrefslogtreecommitdiffhomepage
path: root/lib/axlsx/workbook/workbook.rb
diff options
context:
space:
mode:
authorRandy Morgan <[email protected]>2013-04-28 12:55:46 +0900
committerRandy Morgan <[email protected]>2013-04-28 12:55:46 +0900
commite49aee3e2f700569a519c5346746d239a05383cf (patch)
tree7f449191165a3fbdf05b34c4239dda6ec179d033 /lib/axlsx/workbook/workbook.rb
parenta120fdb2e787986ced4952b6ef3f4b70056960d9 (diff)
downloadcaxlsx-e49aee3e2f700569a519c5346746d239a05383cf.tar.gz
caxlsx-e49aee3e2f700569a519c5346746d239a05383cf.zip
Refactored and renamed space preservation
preserve_spaces has been moved to the workbook and renamed xml_space as that provides a good reference for people trying to figure out what it does, and let's the author specify space preservation for serializations using the shared strings table as well as the default inline serialization in cells.
Diffstat (limited to 'lib/axlsx/workbook/workbook.rb')
-rw-r--r--lib/axlsx/workbook/workbook.rb20
1 files changed, 19 insertions, 1 deletions
diff --git a/lib/axlsx/workbook/workbook.rb b/lib/axlsx/workbook/workbook.rb
index e329ae74..1397552a 100644
--- a/lib/axlsx/workbook/workbook.rb
+++ b/lib/axlsx/workbook/workbook.rb
@@ -285,7 +285,25 @@ require 'axlsx/workbook/worksheet/selection.rb'
# generates a shared string object against all cells in all worksheets.
# @return [SharedStringTable]
def shared_strings
- SharedStringsTable.new(worksheets.collect { |ws| ws.cells })
+ SharedStringsTable.new(worksheets.collect { |ws| ws.cells }, xml_space)
+ end
+
+ # The xml:space attribute for the worksheet.
+ # This determines how whitespace is handled withing the document.
+ # The most relevant part being whitespace in the cell text.
+ # allowed values are :preserve and :default. Axlsx uses :preserve unless
+ # you explicily set this to :default.
+ # @return Symbol
+ def xml_space
+ @xml_space ||= :preserve
+ end
+
+ # Sets the xml:space attribute for the worksheet
+ # @see Worksheet#xml_space
+ # @param [Symbol] space must be one of :preserve or :default
+ def xml_space=(space)
+ Axlsx::RestrictionValidator.validate(:xml_space, [:preserve, :default], space)
+ @xml_space = space;
end
# returns a range of cells in a worksheet