Class: Writexlsx::Chartsheet
- Extended by:
- Forwardable
- Defined in:
- lib/write_xlsx/chartsheet.rb
Constant Summary
Constants included from Utility::StringWidth
Utility::StringWidth::CHAR_WIDTHS, Utility::StringWidth::DEFAULT_COL_PIXELS, Utility::StringWidth::MAX_DIGIT_WIDTH, Utility::StringWidth::PADDING
Constants included from Utility::Common
Utility::Common::PERL_TRUE_VALUES
Constants included from Constants
Writexlsx::Constants::COL_MAX, Writexlsx::Constants::ROW_MAX, Writexlsx::Constants::SHEETNAME_MAX, Writexlsx::Constants::STR_MAX
Constants included from Utility::ChartFormatting
Utility::ChartFormatting::PATTERN_TYPES
Instance Attribute Summary collapse
-
#chart ⇒ Object
writeonly
Sets the attribute chart.
Attributes inherited from Worksheet
#autofilter_area, #col_info, #comments, #comments_author, #data_bars_2010, #default_row_height, #drawings, #dxf_priority, #excel_version, #filter_cells, #index, #name, #row_sizes, #set_rows, #vba_codename, #vml_data_id, #vml_drawing_links, #vml_header_id, #vml_shape_id, #writer
Instance Method Summary collapse
-
#assemble_xml_file ⇒ Object
Assemble and write the XML file.
- #charts ⇒ Object
- #external_links ⇒ Object
-
#initialize(workbook, index, name) ⇒ Chartsheet
constructor
A new instance of Chartsheet.
-
#prepare_chart(_index, chart_id, drawing_id) ⇒ Object
Set up chart/drawings.
- #protect(password = '', user_options = nil, options = {}) ⇒ Object
-
#show_na_as_empty_cell ⇒ Object
Set the option for displaying #N/A as an empty cell in a chart.
Methods inherited from Worksheet
#activate, #data_validation, #date_1904?, #drawings?, #excel2003_style?, #filter_on?, #fit_page?, #fit_to_pages, #has_dynamic_functions?, #has_embedded_images?, #has_shapes?, #hidden?, #hide, #hide_gridlines, #hide_row_col_headers, #horizontal_dpi=, #ignore_errors, #insert_button, #is_chartsheet?, #outline_changed?, #outline_settings, #palette_color, #prepare_tables, #print_row_col_headers, #right_to_left?, #select, #set_background, #set_first_sheet, #set_vba_name, #set_xml_writer, #show_zeros?, #store_formula, #tab_color?, #tables_count, #unprotect_range, #vba_codename?, #vertical_dpi=, #very_hidden, #very_hidden?, #zoom_scale_normal?
Methods included from Worksheet::XmlWriter
#calculate_x_split_width, #col_info_attributes, #increment_rel_id_and_write_r_id, #not_contain_formatting_or_data?, #row_attributes, #sparkline_groups_attributes, #write_auto_filter, #write_autofilters, #write_breaks, #write_brk, #write_cell_array_formula, #write_cell_column_dimension, #write_cell_formula, #write_cell_value, #write_col_breaks, #write_col_info, #write_cols, #write_conditional_formats, #write_conditional_formatting_2010, #write_custom_filter, #write_custom_filters, #write_data_validations, #write_dimension, #write_empty_row, #write_ext, #write_ext_list, #write_ext_list_data_bars, #write_ext_list_sparklines, #write_filter, #write_filter_column, #write_filters, #write_freeze_panes, #write_header_footer, #write_hyperlinks, #write_ignored_error, #write_ignored_errors, #write_merge_cell, #write_merge_cells, #write_outline_pr, #write_page_margins, #write_page_set_up_pr, #write_page_setup, #write_panes, #write_phonetic_pr, #write_print_options, #write_protected_range, #write_protected_ranges, #write_r_id, #write_row_breaks, #write_row_element, #write_rows, #write_selection, #write_selections, #write_sheet_calc_pr, #write_sheet_data, #write_sheet_format_pr, #write_sheet_protection, #write_sheet_view, #write_sheet_views, #write_some_elements, #write_sparkline_groups, #write_split_panes, #write_tab_color, #write_table_part, #write_table_parts, #write_worksheet_attributes, #write_x14_axis_color, #write_x14_border_color, #write_x14_cf_rule, #write_x14_cfvo, #write_x14_data_bar, #write_x14_negative_border_color, #write_x14_negative_fill_color
Methods included from Utility::StringWidth
Methods included from Worksheet::DrawingXmlWriter
#write_drawings, #write_legacy_drawing, #write_legacy_drawing_hf, #write_picture
Methods included from Worksheet::DrawingRelations
#drawing_links, #drawing_rel_index, #get_vml_drawing_rel_index, #set_external_comment_links, #set_external_vml_links
Methods included from Worksheet::DrawingPreparation
#prepare_background, #prepare_background_image, #prepare_drawings, #prepare_header_footer_image, #prepare_header_image, #prepare_header_vml_objects, #prepare_image, #prepare_shape, #prepare_vml_objects
Methods included from Worksheet::DrawingMethods
#add_sparkline, #add_table, #embed_image, #insert_chart, #insert_image, #insert_shape
Methods included from Worksheet::DataWriting
#keep_leading_zeros, #merge_range, #merge_range_type, #prepare_formula, #repeat_formula, #update_format_with_params, #update_range_format_with_params, #write, #write_array_formula, #write_array_formula_base, #write_blank, #write_boolean, #write_col, #write_comment, #write_date_time, #write_dynamic_array_formula, #write_formula, #write_number, #write_rich_string, #write_row, #write_string, #write_url
Methods included from Utility::Common
#absolute_char, #check_parameter, #float_to_str, #ptrue?, #put_deprecate_message
Methods included from Worksheet::RichTextHelpers
#cell_format_of_rich_string, #rich_strings_fragments, #xml_str_of_rich_string
Methods included from Worksheet::CommentsSupport
#buttons_data, #comments_author=, #comments_visible?, #has_comments?, #has_header_vml?, #has_vml?, #header_images_data, #num_comments_block, #set_comments_author, #show_comments, #sorted_comments
Methods included from Worksheet::PrintOptions
#set_h_pagebreaks, #set_landscape, #set_page_view, #set_pagebreak_view, #set_portrait, #set_tab_color, #set_v_pagebreaks, #tab_color=
Methods included from Worksheet::Protection
Methods included from Worksheet::Formatting
#center_horizontally, #center_vertically, #hide_zero, #margin_bottom=, #margin_left=, #margin_right=, #margin_top=, #margins=, #margins_left_right=, #margins_top_bottom=, #paper=, #print_across, #print_area, #print_black_and_white, #print_repeat_cols, #print_repeat_rows, #print_scale=, #repeat_columns, #repeat_rows, #right_to_left, #set_footer, #set_header, #set_margin_bottom, #set_margin_left, #set_margin_right, #set_margin_top, #set_margins, #set_margins_LR, #set_margins_TB, #set_paper, #set_print_scale, #set_start_page, #set_zoom, #start_page=, #zoom=
Methods included from Worksheet::ConditionalFormats
#conditional_formatting, #write_conditional_formatting
Methods included from Worksheet::Autofilter
#autofilter, #filter_column, #filter_column_list, #prepare_filter_column, #write_auto_filter, #write_autofilters, #write_custom_filter, #write_custom_filters, #write_filter, #write_filter_column, #write_filters
Methods included from Worksheet::Panes
#freeze_panes, #set_top_left_cell, #split_panes
Methods included from Worksheet::Selection
Methods included from Worksheet::Rows
#set_default_row, #set_row, #set_row_pixels
Methods included from Worksheet::Columns
#autofit, #set_column, #set_column_pixels
Methods included from ObjectPositioning
#pixels_to_height, #pixels_to_width, #position_object_emus, #position_object_pixels
Methods included from Utility::SheetnameQuoting
Methods included from Utility::XmlPrimitives
#r_id_attributes, #write_color, #write_xml_declaration, #xml_str
Methods included from Utility::Url
Methods included from Utility::DateTime
Methods included from Utility::Dimensions
#check_dimensions, #check_dimensions_and_update_max_min_values, #store_col_max_min_values, #store_row_max_min_values
Methods included from Utility::ChartFormatting
#color, #dash_types, #fill_properties, #layout_properties, #legend_properties, #line_fill_properties, #line_properties, #palette_color_from_index, #pattern_properties, #value_or_raise, #write_a_solid_fill, #write_a_srgb_clr
Methods included from Utility::CellReference
#row_col_notation, #substitute_cellref, #xl_cell_to_rowcol, #xl_col_to_name, #xl_range, #xl_range_formula, #xl_rowcol_to_cell
Methods included from Worksheet::RowColSizing
Methods included from Worksheet::CellDataManager
#get_range_data, #shared_string_index, #store_data_to_table, #store_row_col_max_min_values
Methods included from Worksheet::Initialization
#apply_excel2003_compatibility, #setup_cell_features, #setup_dependencies, #setup_drawing_and_media, #setup_filter_and_selection_state, #setup_identity, #setup_limits, #setup_protection, #setup_row_and_column_state, #setup_sheet_geometry, #setup_view_options, #setup_workbook_dependent_state
Constructor Details
#initialize(workbook, index, name) ⇒ Chartsheet
Returns a new instance of Chartsheet.
42 43 44 45 46 47 48 49 |
# File 'lib/write_xlsx/chartsheet.rb', line 42 def initialize(workbook, index, name) super @drawings = Drawings.new @is_chartsheet = true @chart = nil @zoom_scale_normal = 0 @page_setup.orientation = false end |
Instance Attribute Details
#chart=(value) ⇒ Object (writeonly)
Sets the attribute chart
21 22 23 |
# File 'lib/write_xlsx/chartsheet.rb', line 21 def chart=(value) @chart = value end |
Instance Method Details
#assemble_xml_file ⇒ Object
Assemble and write the XML file.
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/write_xlsx/chartsheet.rb', line 58 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 the worksheet page_margins. write_page_margins # Write the worksheet page setup. write_page_setup # Write the headerFooter element. # Write the drawing element. write_drawings # Write the legaacyDrawingHF element. write_legacy_drawing_hf # Close the worksheet tag. end end end |
#charts ⇒ Object
51 52 53 |
# File 'lib/write_xlsx/chartsheet.rb', line 51 def charts [@chart].compact end |
#external_links ⇒ Object
145 146 147 148 149 150 |
# File 'lib/write_xlsx/chartsheet.rb', line 145 def external_links [ @external_drawing_links, @external_vml_links ] end |
#prepare_chart(_index, chart_id, drawing_id) ⇒ Object
Set up chart/drawings.
133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/write_xlsx/chartsheet.rb', line 133 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
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/write_xlsx/chartsheet.rb', line 87 def protect(password = '', = nil, = {}) # Objects are default on for chartsheets. if [:objects] = if .has_key?(:objects) if ptrue?([:objects]) 0 else 1 end else 0 end [:content] = if .has_key?(:content) [:content] else 1 end else [:objects] = 0 [: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?([:objects]) && !ptrue?([:content]) @chart.protection = 1 # Turn off worksheet defaults. [:sheet] = 0 [:scenarios] = 1 super(password, ) end |
#show_na_as_empty_cell ⇒ Object
Set the option for displaying #N/A as an empty cell in a chart.
126 127 128 |
# File 'lib/write_xlsx/chartsheet.rb', line 126 def show_na_as_empty_cell @chart.show_na_as_empty_cell end |