Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/xlsxwriter/rich_value_structure.py: 24%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

29 statements  

1############################################################################### 

2# 

3# RichValueStructure - A class for writing the Excel XLSX rdrichvaluestructure.xml file. 

4# 

5# SPDX-License-Identifier: BSD-2-Clause 

6# 

7# Copyright (c) 2013-2025, John McNamara, jmcnamara@cpan.org 

8# 

9 

10# Package imports. 

11from . import xmlwriter 

12 

13 

14class RichValueStructure(xmlwriter.XMLwriter): 

15 """ 

16 A class for writing the Excel XLSX rdrichvaluestructure.xml file. 

17 

18 

19 """ 

20 

21 ########################################################################### 

22 # 

23 # Public API. 

24 # 

25 ########################################################################### 

26 

27 def __init__(self): 

28 """ 

29 Constructor. 

30 

31 """ 

32 

33 super().__init__() 

34 self.has_embedded_descriptions = False 

35 

36 ########################################################################### 

37 # 

38 # Private API. 

39 # 

40 ########################################################################### 

41 

42 def _assemble_xml_file(self): 

43 # Assemble and write the XML file. 

44 

45 # Write the XML declaration. 

46 self._xml_declaration() 

47 

48 # Write the rvStructures element. 

49 self._write_rv_structures() 

50 

51 self._xml_end_tag("rvStructures") 

52 

53 # Close the file. 

54 self._xml_close() 

55 

56 ########################################################################### 

57 # 

58 # XML methods. 

59 # 

60 ########################################################################### 

61 def _write_rv_structures(self): 

62 # Write the <rvStructures> element. 

63 xmlns = "http://schemas.microsoft.com/office/spreadsheetml/2017/richdata" 

64 count = "1" 

65 

66 attributes = [ 

67 ("xmlns", xmlns), 

68 ("count", count), 

69 ] 

70 

71 self._xml_start_tag("rvStructures", attributes) 

72 

73 # Write the s element. 

74 self._write_s() 

75 

76 def _write_s(self): 

77 # Write the <s> element. 

78 t = "_localImage" 

79 attributes = [("t", t)] 

80 

81 self._xml_start_tag("s", attributes) 

82 

83 # Write the k elements. 

84 self._write_k("_rvRel:LocalImageIdentifier", "i") 

85 self._write_k("CalcOrigin", "i") 

86 

87 if self.has_embedded_descriptions: 

88 self._write_k("Text", "s") 

89 

90 self._xml_end_tag("s") 

91 

92 def _write_k(self, name, k_type): 

93 # Write the <k> element. 

94 attributes = [ 

95 ("n", name), 

96 ("t", k_type), 

97 ] 

98 

99 self._xml_empty_tag("k", attributes)