module Workbook::Writers::HtmlWriter

Public Instance Methods

to_html(options={}) click to toggle source

Generates an HTML table ()

@param [Hash] options A hash with options @return [String] A String containing the HTML code

# File lib/workbook/writers/html_writer.rb, line 15
def to_html options={}
  builder = Nokogiri::XML::Builder.new do |doc|
    doc.html {
      doc.body {
        self.each{|sheet|
          doc.h1 {
            doc.text sheet.name
          }
          sheet.each{|table|
            doc.h2 {
              doc.text table.name
            }
            doc << table.to_html(options)
          }
        }
      }
    }
  end
  return builder.doc.to_xhtml
end
write_to_html(filename=" click to toggle source

Write the current workbook to HTML format

@param [String] filename @param [Hash] options see to_xls @return [String] filename

# File lib/workbook/writers/html_writer.rb, line 42
def write_to_html filename="#{title}.html", options={}
  File.open(filename, 'w') {|f| f.write(to_html(options)) }
  return filename
end