/usr/lib/python2.7/dist-packages/xlsxwriter/chartsheet.py is in python-xlsxwriter 0.7.3-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 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 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 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | ###############################################################################
#
# Chartsheet - A class for writing the Excel XLSX Worksheet file.
#
# Copyright 2013-2015, John McNamara, jmcnamara@cpan.org
#
from . import worksheet
from .drawing import Drawing
class Chartsheet(worksheet.Worksheet):
"""
A class for writing the Excel XLSX Chartsheet file.
"""
###########################################################################
#
# Public API.
#
###########################################################################
def __init__(self):
"""
Constructor.
"""
super(Chartsheet, self).__init__()
self.is_chartsheet = True
self.drawing = None
self.chart = None
self.charts = []
self.zoom_scale_normal = 0
self.orientation = 0
self.protection = False
def set_chart(self, chart):
"""
Set the chart object for the chartsheet.
Args:
chart: Chart object.
Returns:
chart: A reference to the chart object.
"""
chart.embedded = False
chart.protection = self.protection
self.chart = chart
self.charts.append([0, 0, chart, 0, 0, 1, 1])
return chart
def protect(self, password='', options=None):
"""
Set the password and protection options of the worksheet.
Args:
password: An optional password string.
options: A dictionary of worksheet objects to protect.
Returns:
Nothing.
"""
# Overridden from parent worksheet class.
if self.chart:
self.chart.protection = True
else:
self.protection = True
if not options:
options = {}
options = options.copy()
options['sheet'] = False
options['content'] = True
options['scenarios'] = True
# Call the parent method.
super(Chartsheet, self).protect(password, options)
###########################################################################
#
# Private API.
#
###########################################################################
def _assemble_xml_file(self):
# Assemble and write the XML file.
# Write the XML declaration.
self._xml_declaration()
# Write the root worksheet element.
self._write_chartsheet()
# Write the worksheet properties.
self._write_sheet_pr()
# Write the sheet view properties.
self._write_sheet_views()
# Write the sheetProtection element.
self._write_sheet_protection()
# Write the printOptions element.
self._write_print_options()
# Write the worksheet page_margins.
self._write_page_margins()
# Write the worksheet page setup.
self._write_page_setup()
# Write the headerFooter element.
self._write_header_footer()
# Write the drawing element.
self._write_drawings()
# Close the worksheet tag.
self._xml_end_tag('chartsheet')
# Close the file.
self._xml_close()
def _prepare_chart(self, index, chart_id, drawing_id):
# Set up chart/drawings.
self.chart.id = chart_id - 1
self.drawing = Drawing()
self.drawing.orientation = self.orientation
self.external_drawing_links.append(['/drawing',
'../drawings/drawing'
+ str(drawing_id)
+ '.xml'])
self.drawing_links.append(['/chart',
'../charts/chart'
+ str(chart_id)
+ '.xml'])
###########################################################################
#
# XML methods.
#
###########################################################################
def _write_chartsheet(self):
# Write the <worksheet> element. This is the root element.
schema = 'http://schemas.openxmlformats.org/'
xmlns = schema + 'spreadsheetml/2006/main'
xmlns_r = schema + 'officeDocument/2006/relationships'
attributes = [
('xmlns', xmlns),
('xmlns:r', xmlns_r)]
self._xml_start_tag('chartsheet', attributes)
def _write_sheet_pr(self):
# Write the <sheetPr> element for Sheet level properties.
attributes = []
if self.filter_on:
attributes.append(('filterMode', 1))
if (self.fit_page or self.tab_color):
self._xml_start_tag('sheetPr', attributes)
self._write_tab_color()
self._write_page_set_up_pr()
self._xml_end_tag('sheetPr')
else:
self._xml_empty_tag('sheetPr', attributes)
|