From 171ffca724ba0bbf845af1f4c7712e663500d4e8 Mon Sep 17 00:00:00 2001 From: Adam Mueller Date: Fri, 23 Nov 2012 09:19:56 -0800 Subject: Adds an example of header/footers. Also, header and footer content is now escaped. So that the user doesn't have to worry about that. Change-Id: Ib35b2eca6755d9b2d9974be25887734873d6e64a --- lib/axlsx/workbook/worksheet/header_footer.rb | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'lib') diff --git a/lib/axlsx/workbook/worksheet/header_footer.rb b/lib/axlsx/workbook/worksheet/header_footer.rb index 58e89d9e..20d7b0eb 100644 --- a/lib/axlsx/workbook/worksheet/header_footer.rb +++ b/lib/axlsx/workbook/worksheet/header_footer.rb @@ -1,6 +1,11 @@ module Axlsx # Header/Footer options for printing a worksheet. All settings are optional. # + # Headers and footers are generated using a string which is a combination + # of plain text and control characters. A fairly comprehensive list of control + # characters can be found here: + # https://github.com/randym/axlsx/blob/master/notes_on_header_footer.md + #      # @note The recommended way of managing header/footers is via Worksheet#header_footer # @see Worksheet#initialize class HeaderFooter @@ -41,14 +46,14 @@ module Axlsx serialized_attributes str str << ">" - str << "#{odd_header}" unless odd_header.nil? - str << "#{odd_footer}" unless odd_footer.nil? + str << "#{::CGI.escapeHTML(odd_header)}" unless odd_header.nil? + str << "#{::CGI.escapeHTML(odd_footer)}" unless odd_footer.nil? - str << "#{even_header}" unless even_header.nil? - str << "#{even_footer}" unless even_footer.nil? + str << "#{::CGI.escapeHTML(even_header)}" unless even_header.nil? + str << "#{::CGI.escapeHTML(even_footer)}" unless even_footer.nil? - str << "#{first_header}" unless first_header.nil? - str << "#{first_footer}" unless first_footer.nil? + str << "#{::CGI.escapeHTML(first_header)}" unless first_header.nil? + str << "#{::CGI.escapeHTML(first_footer)}" unless first_footer.nil? str << "" end -- cgit v1.2.3