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

1# -*- coding: windows-1252 -*- 

2 

3from .BIFFRecords import ColInfoRecord 

4 

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 

13 

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 

21 

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 

26 

27 def get_width(self): 

28 return self._width 

29 

30 width = property(get_width, set_width) 

31 

32 def set_style(self, style): 

33 self._xf_index = self._parent_wb.add_style(style) 

34 

35 def width_in_pixels(self): 

36 # *** Approximation **** 

37 return int(round(self.width * 0.0272 + 0.446, 0)) 

38 

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 

45 

46 return ColInfoRecord(self._index, self._index, self.width, self._xf_index, options, self.unused).get() 

47 

48 

49