Class: Writexlsx::Chartsheet

Inherits:
Worksheet show all
Includes:
Utility
Defined in:
lib/write_xlsx/chartsheet.rb

Constant Summary

Constants included from Utility

Utility::CHAR_WIDTHS, Utility::COL_MAX, Utility::DEFAULT_COL_PIXELS, Utility::MAX_DIGIT_WIDTH, Utility::PADDING, Utility::PERL_TRUE_VALUES, Utility::ROW_MAX, Utility::SHEETNAME_MAX, Utility::STR_MAX

Instance Attribute Summary collapse

Attributes inherited from Worksheet

#autofilter_area, #background_image, #charts, #col_info, #comments, #comments_author, #data_bars_2010, #default_row_height, #drawings, #dxf_priority, #excel_version, #filter_cells, #footer_images, #header_images, #images, #index, #name, #row_sizes, #set_rows, #shapes, #tables, #vba_codename, #vml_data_id, #vml_drawing_links, #vml_header_id, #vml_shape_id, #writer

Instance Method Summary collapse

Methods included from Utility

#absolute_char, #check_dimensions, #check_dimensions_and_update_max_min_values, #check_parameter, #color, #convert_date_time, #convert_font_args, #dash_types, delete_files, #escape_url, #fill_properties, #float_to_str, #get_font_latin_attributes, #get_font_style_attributes, #layout_properties, #legend_properties, #line_fill_properties, #line_properties, #palette_color_from_index, #params_to_font, #pattern_properties, #pixels_to_points, #ptrue?, #put_deprecate_message, #quote_sheetname, #r_id_attributes, #row_col_notation, #shape_style_base, #store_col_max_min_values, #store_row_max_min_values, #substitute_cellref, #underline_attributes, #v_shape_attributes_base, #v_shape_style_base, #value_or_raise, #write_a_body_pr, #write_a_def_rpr, #write_a_end_para_rpr, #write_a_lst_style, #write_a_p_formula, #write_a_p_pr_formula, #write_a_solid_fill, #write_a_srgb_clr, #write_anchor, #write_auto_fill, #write_color, #write_comment_path, #write_def_rpr_r_pr_common, #write_div, #write_fill, #write_font, #write_stroke, #write_tx_pr, #write_xml_declaration, #xl_cell_to_rowcol, #xl_col_to_name, #xl_range, #xl_range_formula, #xl_rowcol_to_cell, #xl_string_pixel_width, #xml_str

Methods inherited from Worksheet

#activate, #add_sparkline, #add_table, #autofilter, #autofit, #buttons_data, #center_horizontally, #center_vertically, #comments_visible?, #conditional_formatting, #data_validation, #date_1904?, #drawing_links, #embed_image, #excel2003_style?, #filter_column, #filter_column_list, #fit_to_pages, #freeze_panes, #get_range_data, #has_comments?, #has_dynamic_functions?, #has_embedded_images?, #has_header_vml?, #has_shapes?, #has_vml?, #header_images_data, #hidden?, #hide, #hide_gridlines, #hide_row_col_headers, #hide_zero, #horizontal_dpi=, #ignore_errors, #insert_button, #insert_chart, #insert_image, #insert_shape, #is_chartsheet?, #keep_leading_zeros, #margin_bottom=, #margin_left=, #margin_right=, #margin_top=, #margins=, #margins_left_right=, #margins_top_bottom=, #merge_range, #merge_range_type, #num_comments_block, #outline_settings, #palette_color, #paper=, #position_object_pixels, #prepare_drawings, #prepare_formula, #prepare_header_vml_objects, #prepare_tables, #prepare_vml_objects, #print_across, #print_area, #print_black_and_white, #print_repeat_cols, #print_repeat_rows, #print_row_col_headers, #print_scale=, #repeat_columns, #repeat_formula, #repeat_rows, #right_to_left, #select, #set_background, #set_column, #set_column_pixels, #set_comments_author, #set_default_row, #set_first_sheet, #set_footer, #set_h_pagebreaks, #set_header, #set_landscape, #set_margin_bottom, #set_margin_left, #set_margin_right, #set_margin_top, #set_margins, #set_margins_LR, #set_margins_TB, #set_page_view, #set_pagebreak_view, #set_paper, #set_portrait, #set_print_scale, #set_row, #set_row_pixels, #set_selection, #set_start_page, #set_tab_color, #set_top_left_cell, #set_v_pagebreaks, #set_vba_name, #set_xml_writer, #set_zoom, #show_comments, #some_image_or_drawing_to_be_processed?, #sorted_comments, #split_panes, #start_page=, #store_formula, #tab_color=, #tables_count, #unprotect_range, #update_format_with_params, #update_range_format_with_params, #vertical_dpi=, #very_hidden, #very_hidden?, #write, #write_array_formula, #write_array_formula_base, #write_blank, #write_boolean, #write_cell_array_formula, #write_cell_formula, #write_cell_value, #write_col, #write_comment, #write_date_time, #write_dynamic_array_formula, #write_ext, #write_formula, #write_number, #write_rich_string, #write_row, #write_sparkline_groups, #write_string, #write_url, #zoom=

Constructor Details

#initialize(workbook, index, name) ⇒ Chartsheet

Returns a new instance of Chartsheet.



22
23
24
25
26
27
28
29
30
# File 'lib/write_xlsx/chartsheet.rb', line 22

def initialize(workbook, index, name)
  super
  @drawings          = Drawings.new
  @is_chartsheet     = true
  @chart             = nil
  @charts            = [1]
  @zoom_scale_normal = 0
  @page_setup.orientation = false
end

Instance Attribute Details

#chart=(value) ⇒ Object (writeonly)

Sets the attribute chart

Parameters:

  • value

    the value to set the attribute chart to.



20
21
22
# File 'lib/write_xlsx/chartsheet.rb', line 20

def chart=(value)
  @chart = value
end

Instance Method Details

#add_series(*args) ⇒ Object

Encapsulated Chart methods.



106
107
108
# File 'lib/write_xlsx/chartsheet.rb', line 106

def add_series(*args)
  @chart.add_series(*args)
end

#assemble_xml_fileObject

Assemble and write the XML file.



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/write_xlsx/chartsheet.rb', line 35

def assemble_xml_file # :nodoc:
  return unless @writer

  write_xml_declaration do
    # Write the root chartsheet element.
    write_chartsheet do
      # Write the worksheet properties.
      write_sheet_pr
      # Write the sheet view properties.
      write_sheet_views
      # Write the sheetProtection element.
      write_sheet_protection
      # Write the printOptions element.
      write_print_options
      # Write the worksheet page_margins.
      write_page_margins
      # Write the worksheet page setup.
      write_page_setup
      # Write the headerFooter element.
      write_header_footer
      # Write the drawing element.
      write_drawings
      # Write the legaacyDrawingHF element.
      write_legacy_drawing_hf
      # Close the worksheet tag.
    end
  end
end


193
194
195
196
197
198
# File 'lib/write_xlsx/chartsheet.rb', line 193

def external_links
  [
    @external_drawing_links,
    @external_vml_links
  ]
end

#prepare_chart(_index, chart_id, drawing_id) ⇒ Object

Set up chart/drawings.



181
182
183
184
185
186
187
188
189
190
191
# File 'lib/write_xlsx/chartsheet.rb', line 181

def prepare_chart(_index, chart_id, drawing_id) # :nodoc:
  @chart.id = chart_id - 1

  drawings  = Drawings.new
  @drawings = drawings
  @drawings.orientation = @page_setup.orientation

  @external_drawing_links << ['/drawing', "../drawings/drawing#{drawing_id}.xml"]

  @drawing_links << ['/chart', "../charts/chart#{chart_id}.xml"]
end

#protect(password = '', user_options = nil, options = {}) ⇒ Object



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/write_xlsx/chartsheet.rb', line 64

def protect(password = '', user_options = nil, options = {})
  # Objects are default on for chartsheets.
  if user_options
    options[:objects] = if user_options.has_key?(:objects)
                          if ptrue?(user_options[:objects])
                            0
                          else
                            1
                          end
                        else
                          0
                        end

    options[:content] = if user_options.has_key?(:content)
                          user_options[:content]
                        else
                          1
                        end
  else
    options[:objects] = 0
    options[:content] = 1
  end

  # Is objects and content are off then the chartsheet isn't locked.
  # except if it has a password.
  return if password == '' && ptrue?(options[:objects]) && !ptrue?(options[:content])

  @chart.protection = 1

  # Turn off worksheet defaults.
  options[:sheet]     = 0
  options[:scenarios] = 1

  super(password, options)
end

#set_chartarea(*args) ⇒ Object



138
139
140
# File 'lib/write_xlsx/chartsheet.rb', line 138

def set_chartarea(*args)
  @chart.set_chartarea(*args)
end

#set_drop_lines(*args) ⇒ Object



170
171
172
# File 'lib/write_xlsx/chartsheet.rb', line 170

def set_drop_lines(*args)
  @chart.set_drop_lines(*args)
end

#set_high_low_lines(*args) ⇒ Object



174
175
176
# File 'lib/write_xlsx/chartsheet.rb', line 174

def set_high_low_lines(*args)
  @chart.set_high_low_lines(*args)
end

#set_legend(*args) ⇒ Object



130
131
132
# File 'lib/write_xlsx/chartsheet.rb', line 130

def set_legend(*args)
  @chart.set_legend(*args)
end

#set_plotarea(*args) ⇒ Object



134
135
136
# File 'lib/write_xlsx/chartsheet.rb', line 134

def set_plotarea(*args)
  @chart.set_plotarea(*args)
end

#set_size(*args) ⇒ Object



158
159
160
# File 'lib/write_xlsx/chartsheet.rb', line 158

def set_size(*args)
  @chart.set_size(*args)
end

#set_style(*args) ⇒ Object



142
143
144
# File 'lib/write_xlsx/chartsheet.rb', line 142

def set_style(*args)
  @chart.set_style(*args)
end

#set_table(*args) ⇒ Object



162
163
164
# File 'lib/write_xlsx/chartsheet.rb', line 162

def set_table(*args)
  @chart.set_table(*args)
end

#set_title(*args) ⇒ Object



126
127
128
# File 'lib/write_xlsx/chartsheet.rb', line 126

def set_title(*args)
  @chart.set_title(*args)
end

#set_up_down_bars(*args) ⇒ Object



166
167
168
# File 'lib/write_xlsx/chartsheet.rb', line 166

def set_up_down_bars(*args)
  @chart.set_up_down_bars(*args)
end

#set_x2_axis(*args) ⇒ Object



118
119
120
# File 'lib/write_xlsx/chartsheet.rb', line 118

def set_x2_axis(*args)
  @chart.set_x2_axis(*args)
end

#set_x_axis(*args) ⇒ Object



110
111
112
# File 'lib/write_xlsx/chartsheet.rb', line 110

def set_x_axis(*args)
  @chart.set_x_axis(*args)
end

#set_y2_axis(*args) ⇒ Object



122
123
124
# File 'lib/write_xlsx/chartsheet.rb', line 122

def set_y2_axis(*args)
  @chart.set_y2_axis(*args)
end

#set_y_axis(*args) ⇒ Object



114
115
116
# File 'lib/write_xlsx/chartsheet.rb', line 114

def set_y_axis(*args)
  @chart.set_y_axis(*args)
end

#show_blanks_as(*args) ⇒ Object



146
147
148
# File 'lib/write_xlsx/chartsheet.rb', line 146

def show_blanks_as(*args)
  @chart.show_blanks_as(*args)
end

#show_hidden_data(*args) ⇒ Object



154
155
156
# File 'lib/write_xlsx/chartsheet.rb', line 154

def show_hidden_data(*args)
  @chart.show_hidden_data(*args)
end

#show_na_as_empty_cellObject



150
151
152
# File 'lib/write_xlsx/chartsheet.rb', line 150

def show_na_as_empty_cell
  @chart.show_na_as_empty_cell(*args)
end