Class: Writexlsx::Package::App
- Inherits:
-
Object
- Object
- Writexlsx::Package::App
show all
- Includes:
- Utility
- Defined in:
- lib/write_xlsx/package/app.rb
Constant Summary
Constants included
from Utility
Utility::CHAR_WIDTHS, Utility::COL_MAX, Utility::PERL_TRUE_VALUES, Utility::ROW_MAX, Utility::SHEETNAME_MAX, Utility::STR_MAX
Instance Attribute Summary collapse
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, #get_image_properties, #layout_properties, #legend_properties, #line_fill_properties, #line_properties, #palette_color, #params_to_font, #pattern_properties, #pixels_to_points, #process_bmp, #process_gif, #process_jpg, #process_png, #process_workbook_options, #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
Constructor Details
#initialize(workbook) ⇒ App
Returns a new instance of App.
13
14
15
16
17
18
19
20
|
# File 'lib/write_xlsx/package/app.rb', line 13
def initialize(workbook)
@writer = Package::XMLWriterSimple.new
@workbook = workbook
@part_names = []
@heading_pairs = []
@properties = {}
@doc_security = 0
end
|
Instance Attribute Details
#doc_security=(value) ⇒ Object
Sets the attribute doc_security
11
12
13
|
# File 'lib/write_xlsx/package/app.rb', line 11
def doc_security=(value)
@doc_security = value
end
|
Instance Method Details
#add_chartsheet_heading_pairs ⇒ Object
56
57
58
|
# File 'lib/write_xlsx/package/app.rb', line 56
def add_chartsheet_heading_pairs
add_heading_pair(['Charts', @workbook.chartsheet_count])
end
|
#add_chartsheet_part_names ⇒ Object
68
69
70
71
72
|
# File 'lib/write_xlsx/package/app.rb', line 68
def add_chartsheet_part_names
@workbook.worksheets
.select { |sheet| sheet.is_chartsheet? }
.each { |sheet| add_part_name(sheet.name) }
end
|
#add_heading_pair(heading_pair) ⇒ Object
88
89
90
91
92
|
# File 'lib/write_xlsx/package/app.rb', line 88
def add_heading_pair(heading_pair)
return if heading_pair[1] == 0
@heading_pairs.push(['lpstr', heading_pair[0]], ['i4', heading_pair[1]])
end
|
#add_named_range_heading_pairs ⇒ Object
78
79
80
81
82
|
# File 'lib/write_xlsx/package/app.rb', line 78
def add_named_range_heading_pairs
range_count = @workbook.named_ranges.size
add_heading_pair(['Named Ranges', range_count]) if range_count != 0
end
|
#add_named_ranges_parts ⇒ Object
84
85
86
|
# File 'lib/write_xlsx/package/app.rb', line 84
def add_named_ranges_parts
@workbook.named_ranges.each { |named_range| add_part_name(named_range) }
end
|
#add_part_name(part_name) ⇒ Object
74
75
76
|
# File 'lib/write_xlsx/package/app.rb', line 74
def add_part_name(part_name)
@part_names.push(part_name)
end
|
#add_worksheet_heading_pairs ⇒ Object
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/write_xlsx/package/app.rb', line 45
def add_worksheet_heading_pairs
add_heading_pair(
[
'Worksheets',
@workbook.worksheets.reject do |s|
s.is_chartsheet? || s.very_hidden?
end.count
]
)
end
|
#add_worksheet_part_names ⇒ Object
60
61
62
63
64
65
66
|
# File 'lib/write_xlsx/package/app.rb', line 60
def add_worksheet_part_names
@workbook.worksheets
.reject { |sheet| sheet.is_chartsheet? || sheet.very_hidden? }
.each do |sheet|
add_part_name(sheet.name)
end
end
|
#assemble_xml_file ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/write_xlsx/package/app.rb', line 26
def assemble_xml_file
write_xml_declaration do
write_properties do
write_application
write_doc_security
write_scale_crop
write_heading_pairs
write_titles_of_parts
write_manager
write_company
write_links_up_to_date
write_shared_doc
write_hyperlink_base
write_hyperlinks_changed
write_app_version
end
end
end
|
#set_properties(properties) ⇒ Object
Set the document properties.
97
98
99
|
# File 'lib/write_xlsx/package/app.rb', line 97
def set_properties(properties)
@properties = properties
end
|
#set_xml_writer(filename) ⇒ Object
22
23
24
|
# File 'lib/write_xlsx/package/app.rb', line 22
def set_xml_writer(filename)
@writer.set_xml_writer(filename)
end
|