Class: TableSetting::Stack
- Inherits:
-
Object
- Object
- TableSetting::Stack
- Defined in:
- lib/table_setting/stack.rb
Instance Attribute Summary collapse
-
#sheets ⇒ Object
Returns the value of attribute sheets.
Instance Method Summary collapse
- #cells ⇒ Object
-
#initialize ⇒ Stack
constructor
A new instance of Stack.
- #new_sheet(options = {}) ⇒ Object
- #to_xls ⇒ Object
- #xls_styles ⇒ Object
Constructor Details
#initialize ⇒ Stack
Returns a new instance of Stack.
4 5 6 |
# File 'lib/table_setting/stack.rb', line 4 def initialize @sheets = [] end |
Instance Attribute Details
#sheets ⇒ Object
Returns the value of attribute sheets.
2 3 4 |
# File 'lib/table_setting/stack.rb', line 2 def sheets @sheets end |
Instance Method Details
#cells ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/table_setting/stack.rb', line 8 def cells list = [] sheets.each do |sheet| list += sheet.cells end list end |
#new_sheet(options = {}) ⇒ Object
17 18 19 |
# File 'lib/table_setting/stack.rb', line 17 def new_sheet( = {}) TableSetting::Sheet.new(self, ) end |
#to_xls ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/table_setting/stack.rb', line 21 def to_xls xml = <<-XML <?xml version="1.0"?> <Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:html="http://www.w3.org/TR/REC-html40"> <Styles> #{xls_styles} </Styles> #{sheets.map{|s| s.to_xls(true)}.join} </Workbook> XML xml.strip! end |
#xls_styles ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/table_setting/stack.rb', line 39 def xls_styles signatures = {} cells.each do |cell| next if signatures[cell.style_name] signatures[cell.style_name] = cell.style_xls end xml = '' signatures.each do |signature_class, signature_xls_style| xml += <<-XML <Style ss:ID="#{signature_class}"> #{signature_xls_style} </Style> XML end xml end |