Coverage for /var/srv/projects/api.amasfac.comuna18.com/tmp/venv/lib/python3.9/site-packages/xlwt/Column.py: 28%
34 statements
« prev ^ index » next coverage.py v6.4.4, created at 2023-07-17 14:22 -0600
« prev ^ index » next coverage.py v6.4.4, created at 2023-07-17 14:22 -0600
1# -*- coding: windows-1252 -*-
3from .BIFFRecords import ColInfoRecord
5class Column(object):
6 def __init__(self, colx, parent_sheet):
7 if not(isinstance(colx, int) and 0 <= colx <= 255):
8 raise ValueError("column index (%r) not an int in range(256)" % colx)
9 self._index = colx
10 self._parent = parent_sheet
11 self._parent_wb = parent_sheet.get_parent()
12 self._xf_index = 0x0F
14 self.width = 0x0B92
15 self.hidden = 0
16 self.level = 0
17 self.collapse = 0
18 self.user_set = 0
19 self.best_fit = 0
20 self.unused = 0
22 def set_width(self, width):
23 if not(isinstance(width, int) and 0 <= width <= 65535):
24 raise ValueError("column width (%r) not an int in range(65536)" % width)
25 self._width = width
27 def get_width(self):
28 return self._width
30 width = property(get_width, set_width)
32 def set_style(self, style):
33 self._xf_index = self._parent_wb.add_style(style)
35 def width_in_pixels(self):
36 # *** Approximation ****
37 return int(round(self.width * 0.0272 + 0.446, 0))
39 def get_biff_record(self):
40 options = (self.hidden & 0x01) << 0
41 options |= (self.user_set & 0x01) << 1
42 options |= (self.best_fit & 0x01) << 2
43 options |= (self.level & 0x07) << 8
44 options |= (self.collapse & 0x01) << 12
46 return ColInfoRecord(self._index, self._index, self.width, self._xf_index, options, self.unused).get()