Class: Writexlsx::Package::App
Instance Attribute Summary collapse
Instance Method Summary
collapse
#r_id_attributes, #write_color, #write_xml_declaration, #xml_str
Constructor Details
#initialize(workbook) ⇒ App
Returns a new instance of App.
14
15
16
17
18
19
20
21
|
# File 'lib/write_xlsx/package/app.rb', line 14
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
12
13
14
|
# File 'lib/write_xlsx/package/app.rb', line 12
def doc_security=(value)
@doc_security = value
end
|
Instance Method Details
#add_chartsheet_heading_pairs ⇒ Object
57
58
59
|
# File 'lib/write_xlsx/package/app.rb', line 57
def add_chartsheet_heading_pairs
add_heading_pair(['Charts', @workbook.chartsheet_count])
end
|
#add_chartsheet_part_names ⇒ Object
69
70
71
72
73
|
# File 'lib/write_xlsx/package/app.rb', line 69
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
89
90
91
92
93
|
# File 'lib/write_xlsx/package/app.rb', line 89
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
79
80
81
82
83
|
# File 'lib/write_xlsx/package/app.rb', line 79
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
85
86
87
|
# File 'lib/write_xlsx/package/app.rb', line 85
def add_named_ranges_parts
@workbook.named_ranges.each { |named_range| add_part_name(named_range) }
end
|
#add_part_name(part_name) ⇒ Object
75
76
77
|
# File 'lib/write_xlsx/package/app.rb', line 75
def add_part_name(part_name)
@part_names.push(part_name)
end
|
#add_worksheet_heading_pairs ⇒ Object
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/write_xlsx/package/app.rb', line 46
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
61
62
63
64
65
66
67
|
# File 'lib/write_xlsx/package/app.rb', line 61
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/write_xlsx/package/app.rb', line 27
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.
98
99
100
|
# File 'lib/write_xlsx/package/app.rb', line 98
def set_properties(properties)
@properties = properties
end
|
#set_xml_writer(filename) ⇒ Object
23
24
25
|
# File 'lib/write_xlsx/package/app.rb', line 23
def set_xml_writer(filename)
@writer.set_xml_writer(filename)
end
|