Module: SpreadsheetBuilder
- Defined in:
- lib/spreadsheet_builder.rb,
lib/spreadsheet_builder/data.rb,
lib/spreadsheet_builder/builder.rb,
lib/spreadsheet_builder/palette.rb,
lib/spreadsheet_builder/css_rule.rb,
lib/spreadsheet_builder/css_parser.rb,
lib/spreadsheet_builder/html_parser.rb,
lib/spreadsheet_builder/translations.rb
Defined Under Namespace
Modules: Palette Classes: Builder, CssParser, CssRule, HtmlParser
Constant Summary collapse
- Rgb =
Spreadsheet::Excel::Rgb
- CUSTOM_PALETTE =
{ :xls_color_0 => Rgb.new(0,0,0), :xls_color_1 => Rgb.new(255,255,255), :xls_color_2 => Rgb.new(204,204,204), :xls_color_3 => Rgb.new(249,249,249) }
- PALETTE =
Shade::Palette.new do |p| Rgb.class_variable_get(:@@RGB_MAP).merge(CUSTOM_PALETTE).each do |name, value| p.add("##{value.to_i.to_s(16).ljust(6, "0")}", name.to_s) end end
- TRANSLATIONS =
{}
Class Method Summary collapse
Class Method Details
.from_data(data) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/spreadsheet_builder/data.rb', line 2 def self.from_data(data) builder = Builder.new [:merges, :row_heights, :col_widths].each do |d| if data[d] builder.instance_variable_get("@#{d}".to_sym).merge!(data[d]) end end if data[:sheets] builder.instance_variable_set(:@sheets, data[:sheets]) end if data[:cells] data[:cells].group_by { |c| c[:sheet] }.each do |sheet, cells| sheet ||= 0 if sheet.respond_to?(:to_str) builder.set_sheet_by_name(sheet) else builder.set_sheet(sheet) end cells.each do |cell| # row and col required builder.set_cell_value(cell[:row], cell[:col], cell[:value]) if format = cell[:format] builder.add_format_to_cell(cell[:row], cell[:col], format) end end end end builder end |
.merge(*options) ⇒ Object
Utility
21 22 23 |
# File 'lib/spreadsheet_builder.rb', line 21 def self.merge(*) .inject(&:merge) end |