Class: RubyXL::Worksheet
- Inherits:
-
OOXMLTopLevelObject
- Object
- OOXMLObject
- OOXMLTopLevelObject
- RubyXL::Worksheet
- Defined in:
- lib/rubyXL/objects/worksheet.rb
Overview
Constant Summary collapse
- CONTENT_TYPE =
'application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml'
- REL_TYPE =
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet'
Constants included from WorksheetConvenienceMethods
RubyXL::WorksheetConvenienceMethods::BOLD, RubyXL::WorksheetConvenienceMethods::COLOR, RubyXL::WorksheetConvenienceMethods::ITALICS, RubyXL::WorksheetConvenienceMethods::NAME, RubyXL::WorksheetConvenienceMethods::SIZE, RubyXL::WorksheetConvenienceMethods::STRIKETHROUGH, RubyXL::WorksheetConvenienceMethods::UNDERLINE
Constants inherited from OOXMLTopLevelObject
OOXMLTopLevelObject::ROOT, OOXMLTopLevelObject::SAVE_ORDER
Instance Attribute Summary collapse
-
#rels ⇒ Object
Returns the value of attribute rels.
-
#sheet_id ⇒ Object
Returns the value of attribute sheet_id.
-
#sheet_name ⇒ Object
Returns the value of attribute sheet_name.
-
#state ⇒ Object
Returns the value of attribute state.
-
#workbook ⇒ Object
Returns the value of attribute workbook.
Attributes included from RelationshipSupport
#generic_storage, #relationship_container
Attributes inherited from OOXMLTopLevelObject
Attributes included from OOXMLObjectInstanceMethods
Class Method Summary collapse
Instance Method Summary collapse
-
#before_write_xml ⇒ Object
This method may need to be moved higher in the hierarchy.
- #related_objects ⇒ Object
- #xlsx_path ⇒ Object
Methods included from WorksheetConvenienceMethods
#change_column_alignment, #change_column_bold, #change_column_border, #change_column_border_color, #change_column_fill, #change_column_font, #change_column_font_color, #change_column_font_name, #change_column_font_size, #change_column_horizontal_alignment, #change_column_italics, #change_column_strikethrough, #change_column_underline, #change_column_vertical_alignment, #change_column_width, #change_column_width_raw, #change_row_alignment, #change_row_bold, #change_row_border, #change_row_border_color, #change_row_fill, #change_row_font, #change_row_font_color, #change_row_font_name, #change_row_font_size, #change_row_height, #change_row_horizontal_alignment, #change_row_italics, #change_row_strikethrough, #change_row_underline, #change_row_vertical_alignment, #column_font, #delete_cell, #delete_column, #delete_row, #get_col_style, #get_cols_style_index, #get_column_alignment, #get_column_border, #get_column_border_color, #get_column_fill, #get_column_font_color, #get_column_font_name, #get_column_font_size, #get_column_width, #get_column_width_raw, #get_row_alignment, #get_row_border, #get_row_border_color, #get_row_fill, #get_row_font_color, #get_row_font_name, #get_row_font_size, #get_row_height, #get_row_style, #insert_cell, #insert_column, #insert_row, #is_column_bolded, #is_column_italicized, #is_column_struckthrough, #is_column_underlined, #is_row_bolded, #is_row_italicized, #is_row_struckthrough, #is_row_underlined, #merge_cells, #row_font
Methods included from LegacyWorksheet
#[], #add_cell, #add_row, #each, #initialize
Methods included from RelationshipSupport
#attach_relationship, #collect_related_objects, included, #load_relationships, #store_relationship
Methods inherited from OOXMLTopLevelObject
#add_to_zip, #file_index, parse_file, set_namespaces
Methods included from OOXMLObjectInstanceMethods
#==, included, #index_in_collection, #initialize, #write_xml
Instance Attribute Details
#rels ⇒ Object
Returns the value of attribute rels.
683 684 685 |
# File 'lib/rubyXL/objects/worksheet.rb', line 683 def rels @rels end |
#sheet_id ⇒ Object
Returns the value of attribute sheet_id.
683 684 685 |
# File 'lib/rubyXL/objects/worksheet.rb', line 683 def sheet_id @sheet_id end |
#sheet_name ⇒ Object
Returns the value of attribute sheet_name.
683 684 685 |
# File 'lib/rubyXL/objects/worksheet.rb', line 683 def sheet_name @sheet_name end |
#state ⇒ Object
Returns the value of attribute state.
683 684 685 |
# File 'lib/rubyXL/objects/worksheet.rb', line 683 def state @state end |
#workbook ⇒ Object
Returns the value of attribute workbook.
683 684 685 |
# File 'lib/rubyXL/objects/worksheet.rb', line 683 def workbook @workbook end |
Class Method Details
.parse(param) ⇒ Object
734 735 736 737 738 739 740 741 742 |
# File 'lib/rubyXL/objects/worksheet.rb', line 734 def self.parse(param) sheet_obj = super sheet_obj.sheet_data.rows.each { |r| next if r.nil? r.worksheet = sheet_obj r.cells.each { |c| c.worksheet = sheet_obj unless c.nil? } } sheet_obj end |
Instance Method Details
#before_write_xml ⇒ Object
This method may need to be moved higher in the hierarchy
685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 |
# File 'lib/rubyXL/objects/worksheet.rb', line 685 def before_write_xml # This method may need to be moved higher in the hierarchy first_nonempty_row = nil last_nonempty_row = 0 first_nonempty_column = nil last_nonempty_column = 0 if sheet_data then sheet_data.rows.each_with_index { |row, row_index| next if row.nil? || row.cells.empty? first_nonempty_cell = nil last_nonempty_cell = 0 row.cells.each_with_index { |cell, col_index| next if cell.nil? cell.r = RubyXL::Reference.new(row_index, col_index) first_nonempty_cell ||= col_index last_nonempty_cell = col_index } if first_nonempty_cell then # If there's nothing in this row, then +first_nonempty_cell+ will be +nil+. last_nonempty_row = row_index first_nonempty_row ||= row_index first_nonempty_column ||= first_nonempty_cell last_nonempty_column = last_nonempty_cell if last_nonempty_cell > last_nonempty_column end row.r = row_index + 1 row.spans = "#{first_nonempty_cell + 1}:#{last_nonempty_cell + 1}" unless first_nonempty_cell.nil? row.custom_format = (row.style_index.to_i != 0) } if first_nonempty_row then self.dimension ||= RubyXL::WorksheetDimensions.new self.dimension.ref = RubyXL::Reference.new(first_nonempty_row, last_nonempty_row, first_nonempty_column, last_nonempty_column) end end true end |
#related_objects ⇒ Object
620 621 622 |
# File 'lib/rubyXL/objects/worksheet.rb', line 620 def comments + printer_settings end |
#xlsx_path ⇒ Object
730 731 732 |
# File 'lib/rubyXL/objects/worksheet.rb', line 730 def xlsx_path ROOT.join('xl', 'worksheets', "sheet#{file_index}.xml") end |