lib/axlsx/workbook/worksheet/table.rb in axlsx-1.2.3 vs lib/axlsx/workbook/worksheet/table.rb in axlsx-1.3.1

- old
+ new

@@ -26,10 +26,11 @@ def initialize(ref, sheet, options={}) @ref = ref @sheet = sheet @style = nil @sheet.workbook.tables << self + @table_style_info = TableStyleInfo.new(options[:style_info]) if options[:style_info] @name = "Table#{index+1}" options.each do |o| self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}=" end yield self if block_given? @@ -60,10 +61,16 @@ DataTypeValidator.validate "#{self.class}.name", [String], v if v.is_a?(String) @name = v end end + + # TableStyleInfo for the table. + # initialization can be fed via the :style_info option + def table_style_info + @table_style_info ||= TableStyleInfo.new + end # Serializes the object # @param [String] str # @return [String] def to_xml_string(str = '') @@ -75,10 +82,10 @@ header_cells.each_with_index do |cell,index| str << '<tableColumn id ="' << (index+1).to_s << '" name="' << cell.value << '"/>' end str << '</tableColumns>' #TODO implement tableStyleInfo - str << '<tableStyleInfo showFirstColumn="0" showLastColumn="0" showRowStripes="1" showColumnStripes="0" name="TableStyleMedium9" />' + table_style_info.to_xml_string(str) # '<tableStyleInfo showFirstColumn="0" showLastColumn="0" showRowStripes="1" showColumnStripes="0" name="TableStyleMedium9" />' str << '</table>' end # The style for the table. # TODO