Class: Writexlsx::Chartsheet

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

Constant Summary

Constants included from Utility

Utility::COL_MAX, Utility::ROW_MAX, Utility::SHEETNAME_MAX, Utility::STR_MAX

Instance Attribute Summary collapse

Attributes inherited from Worksheet

#autofilter_area, #charts, #col_formats, #comments_author, #drawing, #drawing_links, #dxf_priority, #external_comment_links, #external_drawing_links, #external_hyper_links, #external_table_links, #external_vml_links, #hlink_refs, #images, #index, #rel_count, #set_rows, #shapes, #tables, #vml_data_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, #convert_date_time, delete_files, #ptrue?, #put_deprecate_message, #row_col_notation, #store_col_max_min_values, #store_row_max_min_values, #substitute_cellref, #underline_attributes, #write_color, #xl_cell_to_rowcol, #xl_col_to_name, #xl_range, #xl_range_formula, #xl_rowcol_to_cell, #xml_str

Methods inherited from Worksheet

#activate, #add_sparkline, #add_table, #autofilter, #center_horizontally, #center_vertically, #comments_array, #comments_assemble_xml_file, #comments_count, #comments_visible?, #comments_xml_writer=, #conditional_formatting, #data_validation, #date_1904?, #filter_column, #filter_column_list, #fit_to_pages, #freeze_panes, #get_palette_color, #get_range_data, #has_comments?, #hidden?, #hide, #hide_gridlines, #hide_zero, #insert_chart, #insert_image, #insert_shape, #is_chartsheet?, #margin_bottom=, #margin_left=, #margin_right=, #margin_top=, #margins=, #margins_left_right=, #margins_top_bottom=, #merge_range, #merge_range_type, #name, #outline_settings, #paper=, #position_object_pixels, #prepare_image, #prepare_shape, #print_across, #print_area, #print_repeat_cols, #print_repeat_rows, #print_row_col_headers, #print_scale=, #repeat_columns, #repeat_formula, #repeat_rows, #right_to_left, #select, #set_column, #set_comments_author, #set_external_comment_links, #set_external_vml_links, #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_paper, #set_portrait, #set_print_scale, #set_row, #set_selection, #set_start_page, #set_tab_color, #set_v_pagebreaks, #set_vml_data_id, #set_xml_writer, #set_zoom, #show_comments, #split_panes, #store_formula, #write, #write_array_formula, #write_blank, #write_cell_array_formula, #write_cell_formula, #write_cell_value, #write_col, #write_comment, #write_date_time, #write_formula, #write_number, #write_rich_string, #write_row, #write_string, #write_url

Constructor Details

#initialize(workbook, index, name) ⇒ Chartsheet

Returns a new instance of Chartsheet.



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

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

Instance Attribute Details

#chart=(value) ⇒ Object (writeonly)

Sets the attribute chart

Parameters:

  • value

    the value to set the attribute chart to.



18
19
20
# File 'lib/write_xlsx/chartsheet.rb', line 18

def chart=(value)
  @chart = value
end

Instance Method Details

#add_series(*args) ⇒ Object

Encapsulated Chart methods.



89
90
91
# File 'lib/write_xlsx/chartsheet.rb', line 89

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

#assemble_xml_fileObject

Assemble and write the XML file.



33
34
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
63
64
65
66
67
68
69
70
# File 'lib/write_xlsx/chartsheet.rb', line 33

def assemble_xml_file # :nodoc:
  return unless @writer
  @writer.xml_decl

  # Write the root chartsheet element.
  write_chartsheet

  # 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

  # Close the worksheet tag.
  @writer.end_tag('chartsheet')

  # Close the XML writer object and filehandle.
  @writer.crlf
  @writer.close
end

#prepare_chart(index, chart_id, drawing_id) ⇒ Object

Set up chart/drawings.



140
141
142
143
144
145
146
147
148
149
150
# File 'lib/write_xlsx/chartsheet.rb', line 140

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

  drawing = Drawing.new
  @drawing = drawing
  @drawing.orientation = @print_style.orientation

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

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

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



72
73
74
75
76
77
78
79
80
# File 'lib/write_xlsx/chartsheet.rb', line 72

def protect(password = '', options = {})
  @chart.protection = 1

  options[:sheet]     = 0
  options[:content]   = 1
  options[:scenarios] = 1

  super(password, options)
end

#set_chartarea(*args) ⇒ Object



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

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

#set_legend(*args) ⇒ Object



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

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

#set_plotarea(*args) ⇒ Object



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

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

#set_style(*args) ⇒ Object



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

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

#set_title(*args) ⇒ Object



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

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

#set_x2_axis(*args) ⇒ Object



101
102
103
# File 'lib/write_xlsx/chartsheet.rb', line 101

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

#set_x_axis(*args) ⇒ Object



93
94
95
# File 'lib/write_xlsx/chartsheet.rb', line 93

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

#set_y2_axis(*args) ⇒ Object



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

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

#set_y_axis(*args) ⇒ Object



97
98
99
# File 'lib/write_xlsx/chartsheet.rb', line 97

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

#show_blanks_as(*args) ⇒ Object



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

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

#show_hidden_data(*args) ⇒ Object



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

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