XlsxWriter 3.3.0__tar.gz → 3.3.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (164) hide show
  1. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/Changes +55 -1
  2. {xlsxwriter-3.3.0/xlsxwriter.egg-info → xlsxwriter-3.3.1}/PKG-INFO +1 -1
  3. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/pyproject.toml +1 -1
  4. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/xlsxwriter/__init__.py +1 -1
  5. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/xlsxwriter/url.py +7 -6
  6. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/xlsxwriter/utility.py +31 -0
  7. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/xlsxwriter/workbook.py +14 -9
  8. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/xlsxwriter/worksheet.py +110 -59
  9. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1/xlsxwriter.egg-info}/PKG-INFO +1 -1
  10. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/LICENSE.txt +0 -0
  11. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/MANIFEST.in +0 -0
  12. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/README.rst +0 -0
  13. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/array_formula.py +0 -0
  14. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/autofilter.py +0 -0
  15. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/autofilter_data.txt +0 -0
  16. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/autofit.py +0 -0
  17. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/autofit_manually.py +0 -0
  18. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/background.py +0 -0
  19. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/cell_indentation.py +0 -0
  20. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/chart.py +0 -0
  21. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/chart_area.py +0 -0
  22. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/chart_bar.py +0 -0
  23. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/chart_clustered.py +0 -0
  24. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/chart_column.py +0 -0
  25. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/chart_combined.py +0 -0
  26. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/chart_data_labels.py +0 -0
  27. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/chart_data_table.py +0 -0
  28. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/chart_data_tools.py +0 -0
  29. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/chart_date_axis.py +0 -0
  30. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/chart_doughnut.py +0 -0
  31. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/chart_gauge.py +0 -0
  32. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/chart_gradient.py +0 -0
  33. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/chart_line.py +0 -0
  34. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/chart_pareto.py +0 -0
  35. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/chart_pattern.py +0 -0
  36. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/chart_pie.py +0 -0
  37. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/chart_radar.py +0 -0
  38. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/chart_scatter.py +0 -0
  39. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/chart_secondary_axis.py +0 -0
  40. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/chart_stock.py +0 -0
  41. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/chart_styles.py +0 -0
  42. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/chartsheet.py +0 -0
  43. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/check_close.py +0 -0
  44. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/checkbox.py +0 -0
  45. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/colors.py +0 -0
  46. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/comments1.py +0 -0
  47. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/comments2.py +0 -0
  48. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/conditional_format.py +0 -0
  49. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/context_manager.py +0 -0
  50. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/data_validate.py +0 -0
  51. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/datetimes.py +0 -0
  52. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/defined_name.py +0 -0
  53. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/demo.py +0 -0
  54. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/diagonal_border.py +0 -0
  55. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/django_simple.py +0 -0
  56. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/doc_properties.py +0 -0
  57. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/dynamic_arrays.py +0 -0
  58. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/embedded_images.py +0 -0
  59. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/headers_footers.py +0 -0
  60. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/hello_world.py +0 -0
  61. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/hide_row_col.py +0 -0
  62. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/hide_sheet.py +0 -0
  63. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/http_server.py +0 -0
  64. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/hyperlink.py +0 -0
  65. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/ignore_errors.py +0 -0
  66. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/images.py +0 -0
  67. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/images_bytesio.py +0 -0
  68. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/inheritance1.py +0 -0
  69. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/inheritance2.py +0 -0
  70. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/lambda.py +0 -0
  71. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/macros.py +0 -0
  72. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/merge1.py +0 -0
  73. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/merge_rich_string.py +0 -0
  74. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/outline.py +0 -0
  75. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/outline_collapsed.py +0 -0
  76. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/pandas_autofilter.py +0 -0
  77. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/pandas_chart.py +0 -0
  78. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/pandas_chart_columns.py +0 -0
  79. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/pandas_chart_line.py +0 -0
  80. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/pandas_column_formats.py +0 -0
  81. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/pandas_conditional_format.py +0 -0
  82. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/pandas_datetime.py +0 -0
  83. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/pandas_header_format.py +0 -0
  84. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/pandas_multiple.py +0 -0
  85. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/pandas_percentage.py +0 -0
  86. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/pandas_positioning.py +0 -0
  87. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/pandas_simple.py +0 -0
  88. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/pandas_table.py +0 -0
  89. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/panes.py +0 -0
  90. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/polars_chart.py +0 -0
  91. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/polars_checkbox.py +0 -0
  92. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/polars_conditional_format.py +0 -0
  93. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/polars_format_custom.py +0 -0
  94. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/polars_format_default.py +0 -0
  95. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/polars_multiple.py +0 -0
  96. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/polars_positioning.py +0 -0
  97. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/polars_simple.py +0 -0
  98. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/polars_sparklines.py +0 -0
  99. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/polars_xlsxwriter.py +0 -0
  100. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/rich_strings.py +0 -0
  101. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/right_to_left.py +0 -0
  102. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/sensitivity_label.py +0 -0
  103. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/sparklines1.py +0 -0
  104. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/sparklines2.py +0 -0
  105. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/tab_colors.py +0 -0
  106. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/tables.py +0 -0
  107. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/text_indent.py +0 -0
  108. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/textbox.py +0 -0
  109. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/tutorial1.py +0 -0
  110. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/tutorial2.py +0 -0
  111. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/tutorial3.py +0 -0
  112. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/unicode.py +0 -0
  113. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/unicode_polish_utf8.py +0 -0
  114. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/unicode_polish_utf8.txt +0 -0
  115. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/unicode_shift_jis.py +0 -0
  116. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/unicode_shift_jis.txt +0 -0
  117. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/user_types1.py +0 -0
  118. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/user_types2.py +0 -0
  119. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/user_types3.py +0 -0
  120. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/vbaProject.bin +0 -0
  121. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/vba_extract.py +0 -0
  122. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/watermark.py +0 -0
  123. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/examples/worksheet_protection.py +0 -0
  124. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/setup.cfg +0 -0
  125. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/xlsxwriter/app.py +0 -0
  126. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/xlsxwriter/chart.py +0 -0
  127. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/xlsxwriter/chart_area.py +0 -0
  128. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/xlsxwriter/chart_bar.py +0 -0
  129. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/xlsxwriter/chart_column.py +0 -0
  130. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/xlsxwriter/chart_doughnut.py +0 -0
  131. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/xlsxwriter/chart_line.py +0 -0
  132. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/xlsxwriter/chart_pie.py +0 -0
  133. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/xlsxwriter/chart_radar.py +0 -0
  134. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/xlsxwriter/chart_scatter.py +0 -0
  135. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/xlsxwriter/chart_stock.py +0 -0
  136. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/xlsxwriter/chart_title.py +0 -0
  137. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/xlsxwriter/chartsheet.py +0 -0
  138. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/xlsxwriter/color.py +0 -0
  139. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/xlsxwriter/comments.py +0 -0
  140. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/xlsxwriter/contenttypes.py +0 -0
  141. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/xlsxwriter/core.py +0 -0
  142. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/xlsxwriter/custom.py +0 -0
  143. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/xlsxwriter/drawing.py +0 -0
  144. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/xlsxwriter/exceptions.py +0 -0
  145. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/xlsxwriter/feature_property_bag.py +0 -0
  146. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/xlsxwriter/format.py +0 -0
  147. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/xlsxwriter/image.py +0 -0
  148. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/xlsxwriter/metadata.py +0 -0
  149. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/xlsxwriter/packager.py +0 -0
  150. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/xlsxwriter/relationships.py +0 -0
  151. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/xlsxwriter/rich_value.py +0 -0
  152. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/xlsxwriter/rich_value_rel.py +0 -0
  153. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/xlsxwriter/rich_value_structure.py +0 -0
  154. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/xlsxwriter/rich_value_types.py +0 -0
  155. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/xlsxwriter/shape.py +0 -0
  156. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/xlsxwriter/sharedstrings.py +0 -0
  157. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/xlsxwriter/styles.py +0 -0
  158. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/xlsxwriter/table.py +0 -0
  159. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/xlsxwriter/theme.py +0 -0
  160. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/xlsxwriter/vml.py +0 -0
  161. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/xlsxwriter/xmlwriter.py +0 -0
  162. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/xlsxwriter.egg-info/SOURCES.txt +0 -0
  163. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/xlsxwriter.egg-info/dependency_links.txt +0 -0
  164. {xlsxwriter-3.3.0 → xlsxwriter-3.3.1}/xlsxwriter.egg-info/top_level.txt +0 -0
@@ -1,4 +1,58 @@
1
1
 
2
+ Release 3.3.1 - October 28 2026
3
+ -------------------------------
4
+
5
+ * Fixed performance issue where positioning objects such as images and comments
6
+ on a worksheet with a custom default row height.
7
+
8
+ :issue:`1210`.
9
+
10
+ * Fixed a (different) performance issue where positioning a large number of
11
+ objects such as comments on a worksheet with custom row heights or column
12
+ widths.
13
+
14
+ :issue:`1217`.
15
+
16
+ * Fixed off by one error in the worksheet :func:`set_first_sheet()` method.
17
+
18
+ :issue:`1187`.
19
+
20
+ * Fixed issue where :func:`autofit()` hid a column that had a user defined
21
+ width narrower than the autofit width.
22
+
23
+ :issue:`1219`.
24
+
25
+ * Fixed issue where :func:`add_table()` didn't detect a duplicate header name
26
+ when a user defined header matched a default ``ColumnN`` header.
27
+
28
+ :issue:`1215`.
29
+
30
+ * Fixed issue where the ``strings_to_formulas`` Workbook option didn't prevent
31
+ :func:`write()` from converting strings like ``{=SUM(A1:B1*A2:B2)}`` to
32
+ array formulas.
33
+
34
+ :issue:`1212`.
35
+
36
+ * Fixed :func:`set_column()` rounding a half-pixel width to the nearest even
37
+ pixel, which made some widths one pixel narrower than in 3.2.9.
38
+
39
+ :issue:`1221`.
40
+
41
+ * Fixed unescaped double quotes, and incorrect string lengths for characters
42
+ such as emojis, in ``text`` type conditional formats.
43
+
44
+ :issue:`1206`.
45
+
46
+ * Fixed issue where "future" functions such as ``ISFORMULA()`` weren't prefixed
47
+ with ``_xlfn.`` in :func:`conditional_format()` and :func:`data_validation()`
48
+ formulas. See :ref:`formula_future`.
49
+
50
+ :issue:`1171`.
51
+
52
+ * Fixed Excel string length limit checks for strings with characters such as
53
+ emojis, which Excel counts as 2 characters.
54
+
55
+
2
56
  Release 3.3.0 - October 22 2026
3
57
  -------------------------------
4
58
 
@@ -38,7 +92,7 @@ Release 3.3.0 - October 22 2026
38
92
  * Fixed the width and height detection for large GIF images and for top-down
39
93
  BMP images, and added extra image dimension validation.
40
94
 
41
- :issue:`1188` and :issue:`1189`.
95
+ :pull:`1188` and :pull:`1189`.
42
96
 
43
97
  * Migrated the packaging configuration from ``setup.py`` to ``pyproject.toml``
44
98
  with the license declared as a PEP 639 SPDX expression.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: xlsxwriter
3
- Version: 3.3.0
3
+ Version: 3.3.1
4
4
  Summary: A Python module for creating Excel XLSX files.
5
5
  Author-email: John McNamara <jmcnamara@cpan.org>
6
6
  License-Expression: BSD-2-Clause
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "xlsxwriter"
7
- version = "3.3.0"
7
+ version = "3.3.1"
8
8
  description = "A Python module for creating Excel XLSX files."
9
9
  readme = "README.rst"
10
10
  license = "BSD-2-Clause"
@@ -3,7 +3,7 @@
3
3
  #
4
4
  # Copyright (c) 2013-2026, John McNamara, jmcnamara@cpan.org
5
5
  #
6
- __version__ = "3.3.0"
6
+ __version__ = "3.3.1"
7
7
  __VERSION__ = __version__
8
8
  from xlsxwriter.workbook import Workbook
9
9
 
@@ -12,6 +12,8 @@ import re
12
12
  from enum import Enum
13
13
  from typing import Any, Dict, Optional
14
14
 
15
+ from xlsxwriter.utility import _utf16_len
16
+
15
17
 
16
18
  class UrlTypes(Enum):
17
19
  """
@@ -46,15 +48,12 @@ class Url:
46
48
 
47
49
  self._parse_url()
48
50
 
49
- if len(self._link) > self.MAX_URL_LEN:
51
+ if _utf16_len(self._link) > self.MAX_URL_LEN:
50
52
  raise ValueError("URL exceeds Excel's maximum length.")
51
53
 
52
- if len(self._anchor) > self.MAX_URL_LEN:
54
+ if _utf16_len(self._anchor) > self.MAX_URL_LEN:
53
55
  raise ValueError("Anchor segment or url exceeds Excel's maximum length.")
54
56
 
55
- if len(self._tip) > self.MAX_PARAMETER_LEN:
56
- raise ValueError("Hyperlink tool tip exceeds Excel's maximum length.")
57
-
58
57
  self._escape_strings()
59
58
 
60
59
  def __repr__(self) -> str:
@@ -98,7 +97,7 @@ class Url:
98
97
  if isinstance(url, str):
99
98
  url = cls(options["url"])
100
99
  if options.get("tip"):
101
- url._tip = options["tip"]
100
+ url.tip = options["tip"]
102
101
 
103
102
  return url
104
103
 
@@ -120,6 +119,8 @@ class Url:
120
119
  @tip.setter
121
120
  def tip(self, value: str) -> None:
122
121
  """Set the screen tip for the URL."""
122
+ if _utf16_len(value) > self.MAX_PARAMETER_LEN:
123
+ raise ValueError("Hyperlink tool tip exceeds Excel's maximum length.")
123
124
  self._tip = value
124
125
 
125
126
  def _parse_url(self) -> None:
@@ -133,6 +133,10 @@ RE_QUOTE_RULE2 = re.compile(rf"^[\d\.{EMOJIS}]")
133
133
  RE_QUOTE_RULE3 = re.compile(r"^([A-Z]{1,3}\d+)$")
134
134
  RE_QUOTE_RULE4_ROW = re.compile(r"^R(\d+)")
135
135
  RE_QUOTE_RULE4_COLUMN = re.compile(r"^R?C(\d+)")
136
+ RE_INVALID_NAME_CHARS = re.compile(
137
+ r"[ !\"#$%&'()*+,\-/:;<=>@\[\]^`{|}~\x00-\x1f\x7f-\x9f]"
138
+ )
139
+ RE_INVALID_NAME_START = re.compile(r"^[\d.?]")
136
140
 
137
141
 
138
142
  def xl_rowcol_to_cell(
@@ -948,3 +952,30 @@ def _preserve_whitespace(string: str) -> Optional[re.Match]:
948
952
  # Check if a string has leading or trailing whitespace that requires a
949
953
  # "preserve" attribute.
950
954
  return RE_LEADING_WHITESPACE.search(string) or RE_TRAILING_WHITESPACE.search(string)
955
+
956
+
957
+ def _utf16_len(string: str) -> int:
958
+ # Get the length of a string in UTF-16 units. Excel's string length limits
959
+ # are in UTF-16 units, so characters above U+FFFF, such as emojis, count as 2.
960
+ return len(string.encode("utf-16-le", "surrogatepass")) // 2
961
+
962
+
963
+ def _utf16_truncate(string: str, max_len: int) -> str:
964
+ # Truncate a string to a maximum length in UTF-16 units without splitting
965
+ # a character above U+FFFF.
966
+ length = 0
967
+ for index, char in enumerate(string):
968
+ length += 2 if ord(char) > 0xFFFF else 1
969
+ if length > max_len:
970
+ return string[:index]
971
+
972
+ return string
973
+
974
+
975
+ def _has_invalid_name_chars(name: str) -> bool:
976
+ # Check for characters that Excel doesn't allow in defined and table names.
977
+ return (
978
+ not name
979
+ or bool(RE_INVALID_NAME_CHARS.search(name))
980
+ or bool(RE_INVALID_NAME_START.match(name))
981
+ )
@@ -46,7 +46,7 @@ from xlsxwriter.image import Image
46
46
  from xlsxwriter.packager import Packager
47
47
  from xlsxwriter.sharedstrings import SharedStringTable
48
48
  from xlsxwriter.theme import THEME_XML_2007, THEME_XML_2023
49
- from xlsxwriter.utility import xl_cell_to_rowcol
49
+ from xlsxwriter.utility import _has_invalid_name_chars, _utf16_len, xl_cell_to_rowcol
50
50
  from xlsxwriter.worksheet import Worksheet
51
51
 
52
52
 
@@ -601,13 +601,13 @@ class Workbook(xmlwriter.XMLwriter):
601
601
  if property_type in ("number", "number_int"):
602
602
  value = str(value)
603
603
 
604
- if property_type == "text" and len(value) > 255:
604
+ if property_type == "text" and _utf16_len(value) > 255:
605
605
  warn(
606
606
  f"Length of 'value' parameter exceeds Excel's limit of 255 "
607
607
  f"characters in set_custom_property(): '{value}'"
608
608
  )
609
609
 
610
- if len(name) > 255:
610
+ if _utf16_len(name) > 255:
611
611
  warn(
612
612
  f"Length of 'name' parameter exceeds Excel's limit of 255 "
613
613
  f"characters in set_custom_property(): '{name}'"
@@ -683,12 +683,18 @@ class Workbook(xmlwriter.XMLwriter):
683
683
  sheet_index = -1
684
684
 
685
685
  # Warn if the defined name contains invalid chars as defined by Excel.
686
- if not re.match(r"^[\w\\][\w\\.]*$", name, re.UNICODE) or re.match(
687
- r"^\d", name
688
- ):
686
+ if _has_invalid_name_chars(name):
689
687
  warn(f"Invalid Excel characters in defined_name(): '{name}'")
690
688
  return -1
691
689
 
690
+ # Warn if the defined name exceeds Excel's maximum length.
691
+ if _utf16_len(name) > 255:
692
+ warn(
693
+ f"Name '{name}' in define_name() exceeds Excel's limit of 255 "
694
+ f"characters"
695
+ )
696
+ return -1
697
+
692
698
  # Warn if the defined name looks like a cell name.
693
699
  if re.match(r"^[a-zA-Z][a-zA-Z]?[a-dA-D]?\d+$", name):
694
700
  warn(f"Name looks like a cell name in defined_name(): '{name}'")
@@ -994,7 +1000,7 @@ class Workbook(xmlwriter.XMLwriter):
994
1000
  sheetname = self.sheet_name + str(self.sheetname_count)
995
1001
 
996
1002
  # Check that sheet sheetname is <= 31. Excel limit.
997
- if len(sheetname) > 31:
1003
+ if _utf16_len(sheetname) > 31:
998
1004
  raise InvalidWorksheetName(
999
1005
  f"Excel worksheet name '{sheetname}' must be <= 31 chars."
1000
1006
  )
@@ -1832,8 +1838,7 @@ class Workbook(xmlwriter.XMLwriter):
1832
1838
 
1833
1839
  # Store the firstSheet attribute when it isn't the default.
1834
1840
  if self.worksheet_meta.firstsheet > 0:
1835
- firstsheet = self.worksheet_meta.firstsheet + 1
1836
- attributes.append(("firstSheet", firstsheet))
1841
+ attributes.append(("firstSheet", self.worksheet_meta.firstsheet))
1837
1842
 
1838
1843
  # Store the activeTab attribute when it isn't the first sheet.
1839
1844
  if self.worksheet_meta.activesheet > 0:
@@ -49,8 +49,11 @@ from xlsxwriter.url import Url, UrlTypes
49
49
  from xlsxwriter.utility import (
50
50
  _datetime_to_excel_datetime,
51
51
  _get_sparkline_style,
52
+ _has_invalid_name_chars,
52
53
  _preserve_whitespace,
53
54
  _supported_datetime,
55
+ _utf16_len,
56
+ _utf16_truncate,
54
57
  quote_sheetname,
55
58
  xl_cell_to_rowcol,
56
59
  xl_col_to_name,
@@ -445,7 +448,11 @@ class Worksheet(xmlwriter.XMLwriter):
445
448
 
446
449
  self.row_sizes = {}
447
450
  self.col_size_changed = False
448
- self.row_size_changed = False
451
+
452
+ # The previously calculated (index, pixel offset) used to position
453
+ # objects, to avoid re-summing the sizes from the first row/col.
454
+ self.prev_col_offset = (0, 0)
455
+ self.prev_row_offset = (0, 0)
449
456
 
450
457
  self.rel_count = 0
451
458
  self.hlink_count = 0
@@ -528,7 +535,7 @@ class Worksheet(xmlwriter.XMLwriter):
528
535
  if self.strings_to_formulas and token.startswith("="):
529
536
  return self._write_formula(row, col, *args)
530
537
 
531
- if token.startswith("{=") and token.endswith("}"):
538
+ if self.strings_to_formulas and token.startswith("{=") and token.endswith("}"):
532
539
  return self._write_formula(row, col, *args)
533
540
 
534
541
  # pylint: disable=too-many-boolean-expressions
@@ -694,9 +701,10 @@ class Worksheet(xmlwriter.XMLwriter):
694
701
  if self._check_dimensions(row, col):
695
702
  return -1
696
703
 
697
- # Check that the string is < 32767 chars.
698
- if len(string) > self.xls_strmax:
699
- string = string[: self.xls_strmax]
704
+ # Check that the string is < 32767 UTF-16 units. A string can't exceed
705
+ # the limit if it is less than half of it, so skip the slower check.
706
+ if len(string) > self.xls_strmax // 2 and _utf16_len(string) > self.xls_strmax:
707
+ string = _utf16_truncate(string, self.xls_strmax)
700
708
  str_error = -2
701
709
 
702
710
  # Write a shared string or an in-line string in constant_memory mode.
@@ -1389,7 +1397,7 @@ class Worksheet(xmlwriter.XMLwriter):
1389
1397
  url_str = url
1390
1398
  anchor_str = ""
1391
1399
 
1392
- if len(url_str) > max_url or len(anchor_str) > max_url:
1400
+ if _utf16_len(url_str) > max_url or _utf16_len(anchor_str) > max_url:
1393
1401
  warn(
1394
1402
  f"Ignoring URL '{url}' with link or location/anchor > {max_url} "
1395
1403
  f"characters since it exceeds Excel's limit for URLs."
@@ -1402,7 +1410,7 @@ class Worksheet(xmlwriter.XMLwriter):
1402
1410
  url._text = string
1403
1411
 
1404
1412
  if tip is not None:
1405
- url._tip = tip
1413
+ url.tip = tip
1406
1414
 
1407
1415
  # Check the limit of URLs per worksheet.
1408
1416
  self.hlink_count += 1
@@ -1550,7 +1558,7 @@ class Worksheet(xmlwriter.XMLwriter):
1550
1558
  string = self.rstring.fh.getvalue()
1551
1559
 
1552
1560
  # Check that the string is < 32767 chars.
1553
- if len(raw_string) > self.xls_strmax:
1561
+ if _utf16_len(raw_string) > self.xls_strmax:
1554
1562
  warn(
1555
1563
  "String length must be less than or equal to Excel's limit "
1556
1564
  "of 32,767 characters in write_rich_string()."
@@ -1879,7 +1887,7 @@ class Worksheet(xmlwriter.XMLwriter):
1879
1887
  return -1
1880
1888
 
1881
1889
  # Check that the comment string is < 32767 chars.
1882
- if len(comment) > self.xls_strmax:
1890
+ if _utf16_len(comment) > self.xls_strmax:
1883
1891
  return -2
1884
1892
 
1885
1893
  self.has_vml = True
@@ -2075,9 +2083,9 @@ class Worksheet(xmlwriter.XMLwriter):
2075
2083
  elif width == 0.0:
2076
2084
  width_pixels = 0
2077
2085
  elif width < 1.0:
2078
- width_pixels = round(width * (self.max_digit_width + self.cell_padding))
2086
+ width_pixels = int(width * (self.max_digit_width + self.cell_padding) + 0.5)
2079
2087
  else:
2080
- width_pixels = round(width * self.max_digit_width) + self.cell_padding
2088
+ width_pixels = int(width * self.max_digit_width + 0.5) + self.cell_padding
2081
2089
 
2082
2090
  return self.set_column_pixels(
2083
2091
  first_col, last_col, width_pixels, cell_format, options
@@ -2295,15 +2303,15 @@ class Worksheet(xmlwriter.XMLwriter):
2295
2303
  # to pre-load a minimum col width.
2296
2304
  col_info = self.col_info.get(col_num)
2297
2305
  user_width = col_info.width
2298
- hidden = col_info.hidden
2299
- if user_width is not None and not hidden:
2306
+ autofit = col_info.autofit
2307
+ if user_width is not None and not autofit:
2300
2308
  # Col info is user defined.
2301
2309
  if width > user_width:
2302
2310
  self.col_info[col_num].width = width
2303
- self.col_info[col_num].hidden = True
2311
+ self.col_info[col_num].autofit = True
2304
2312
  else:
2305
2313
  self.col_info[col_num].width = width
2306
- self.col_info[col_num].hidden = True
2314
+ self.col_info[col_num].autofit = True
2307
2315
  else:
2308
2316
  self.col_info[col_num] = ColumnInfo(
2309
2317
  width=width,
@@ -2332,7 +2340,7 @@ class Worksheet(xmlwriter.XMLwriter):
2332
2340
 
2333
2341
  """
2334
2342
  if height is not None:
2335
- pixel_height = round(height * 4.0 / 3.0)
2343
+ pixel_height = int(height * 4.0 / 3.0 + 0.5)
2336
2344
  else:
2337
2345
  pixel_height = None
2338
2346
 
@@ -2400,9 +2408,6 @@ class Worksheet(xmlwriter.XMLwriter):
2400
2408
  collapsed=collapsed,
2401
2409
  )
2402
2410
 
2403
- # Store the row change to allow optimizations.
2404
- self.row_size_changed = True
2405
-
2406
2411
  # Store the row sizes for use when calculating image vertices.
2407
2412
  self.row_sizes[row] = [height, hidden]
2408
2413
 
@@ -2425,11 +2430,9 @@ class Worksheet(xmlwriter.XMLwriter):
2425
2430
  if height is None:
2426
2431
  pixel_height = self.default_row_height
2427
2432
  else:
2428
- pixel_height = int(round(height * 4.0 / 3.0)) # noqa: RUF046
2433
+ pixel_height = int(height * 4.0 / 3.0 + 0.5)
2429
2434
 
2430
2435
  if pixel_height != self.original_row_height:
2431
- # Store the row change to allow optimizations.
2432
- self.row_size_changed = True
2433
2436
  self.default_row_height = pixel_height
2434
2437
 
2435
2438
  if hide_unused_rows:
@@ -2871,7 +2874,7 @@ class Worksheet(xmlwriter.XMLwriter):
2871
2874
  options["maximum"] = f"{date_time:.16g}"
2872
2875
 
2873
2876
  # Check that the input title doesn't exceed the maximum length.
2874
- if options.get("input_title") and len(options["input_title"]) > 32:
2877
+ if options.get("input_title") and _utf16_len(options["input_title"]) > 32:
2875
2878
  warn(
2876
2879
  f"Length of input title '{options['input_title']}' "
2877
2880
  f"exceeds Excel's limit of 32"
@@ -2879,7 +2882,7 @@ class Worksheet(xmlwriter.XMLwriter):
2879
2882
  return -2
2880
2883
 
2881
2884
  # Check that the error title doesn't exceed the maximum length.
2882
- if options.get("error_title") and len(options["error_title"]) > 32:
2885
+ if options.get("error_title") and _utf16_len(options["error_title"]) > 32:
2883
2886
  warn(
2884
2887
  f"Length of error title '{options['error_title']}' "
2885
2888
  f"exceeds Excel's limit of 32"
@@ -2887,7 +2890,7 @@ class Worksheet(xmlwriter.XMLwriter):
2887
2890
  return -2
2888
2891
 
2889
2892
  # Check that the input message doesn't exceed the maximum length.
2890
- if options.get("input_message") and len(options["input_message"]) > 255:
2893
+ if options.get("input_message") and _utf16_len(options["input_message"]) > 255:
2891
2894
  warn(
2892
2895
  f"Length of input message '{options['input_message']}' "
2893
2896
  f"exceeds Excel's limit of 255"
@@ -2895,7 +2898,7 @@ class Worksheet(xmlwriter.XMLwriter):
2895
2898
  return -2
2896
2899
 
2897
2900
  # Check that the error message doesn't exceed the maximum length.
2898
- if options.get("error_message") and len(options["error_message"]) > 255:
2901
+ if options.get("error_message") and _utf16_len(options["error_message"]) > 255:
2899
2902
  warn(
2900
2903
  f"Length of error message '{options['error_message']}' "
2901
2904
  f"exceeds Excel's limit of 255"
@@ -2905,7 +2908,7 @@ class Worksheet(xmlwriter.XMLwriter):
2905
2908
  # Check that the input list doesn't exceed the maximum length.
2906
2909
  if options["validate"] == "list" and isinstance(options["value"], list):
2907
2910
  formula = self._csv_join(*options["value"])
2908
- if len(formula) > 255:
2911
+ if _utf16_len(formula) > 255:
2909
2912
  warn(
2910
2913
  f"Length of list items '{formula}' exceeds Excel's limit of "
2911
2914
  f"255, use a formula range instead"
@@ -3230,9 +3233,14 @@ class Worksheet(xmlwriter.XMLwriter):
3230
3233
  # Special handling of text criteria.
3231
3234
  if options["type"] == "text":
3232
3235
  value = options["value"]
3233
- length = len(value)
3234
3236
  criteria = options["criteria"]
3235
3237
 
3238
+ # Excel string lengths are in UTF-16 units.
3239
+ length = len(value.encode("utf-16-le")) // 2
3240
+
3241
+ # Excel requires that double quotes in formula strings are doubled.
3242
+ value = value.replace('"', '""')
3243
+
3236
3244
  if options["criteria"] == "containsText":
3237
3245
  options["type"] = "containsText"
3238
3246
  options["formula"] = f'NOT(ISERROR(SEARCH("{value}",{start_cell})))'
@@ -3553,7 +3561,7 @@ class Worksheet(xmlwriter.XMLwriter):
3553
3561
  num_rows -= 1
3554
3562
 
3555
3563
  if num_rows < 0:
3556
- warn("Must have at least one data row in in add_table()")
3564
+ warn("Must have at least one data row in add_table()")
3557
3565
  return -2
3558
3566
 
3559
3567
  # Set the table options.
@@ -3576,12 +3584,18 @@ class Worksheet(xmlwriter.XMLwriter):
3576
3584
  return -2
3577
3585
 
3578
3586
  # Warn if the name contains invalid chars as defined by Excel.
3579
- if not re.match(r"^[\w\\][\w\\.]*$", name, re.UNICODE) or re.match(
3580
- r"^\d", name
3581
- ):
3587
+ if _has_invalid_name_chars(name):
3582
3588
  warn(f"Invalid Excel characters in add_table(): '{name}'")
3583
3589
  return -2
3584
3590
 
3591
+ # Warn if the name exceeds Excel's maximum length.
3592
+ if _utf16_len(name) > 255:
3593
+ warn(
3594
+ f"Name '{name}' in add_table() exceeds Excel's limit of 255 "
3595
+ f"characters"
3596
+ )
3597
+ return -2
3598
+
3585
3599
  # Warn if the name looks like a cell name.
3586
3600
  if re.match(r"^[a-zA-Z][a-zA-Z]?[a-dA-D]?\d+$", name):
3587
3601
  warn(f"Name looks like a cell name in add_table(): '{name}'")
@@ -3627,10 +3641,29 @@ class Worksheet(xmlwriter.XMLwriter):
3627
3641
  if options["autofilter"]:
3628
3642
  table["autofilter"] = table["a_range"]
3629
3643
 
3644
+ # Excel requires unique case insensitive header names. Check the user
3645
+ # defined and default names before any table data is written.
3646
+ seen_names = set()
3647
+ user_columns = options.get("columns", [])
3648
+
3649
+ for col_id in range(1, last_col - first_col + 2):
3650
+ name = "Column" + str(col_id)
3651
+
3652
+ if col_id <= len(user_columns):
3653
+ user_data = user_columns[col_id - 1]
3654
+ if user_data and user_data.get("header"):
3655
+ name = user_data["header"]
3656
+
3657
+ name = name.lower()
3658
+ if name in seen_names:
3659
+ warn(f"Duplicate header name in add_table(): '{name}'")
3660
+ return -2
3661
+
3662
+ seen_names.add(name)
3663
+
3630
3664
  # Add the table columns.
3631
3665
  col_id = 1
3632
3666
  table["columns"] = []
3633
- seen_names = {}
3634
3667
 
3635
3668
  for col_num in range(first_col, last_col + 1):
3636
3669
  # Set up the default column data.
@@ -3662,15 +3695,6 @@ class Worksheet(xmlwriter.XMLwriter):
3662
3695
  if user_data.get("header"):
3663
3696
  col_data["name"] = user_data["header"]
3664
3697
 
3665
- # Excel requires unique case insensitive header names.
3666
- header_name = col_data["name"]
3667
- name = header_name.lower()
3668
- if name in seen_names:
3669
- warn(f"Duplicate header name in add_table(): '{name}'")
3670
- return -2
3671
-
3672
- seen_names[name] = True
3673
-
3674
3698
  col_data["name_format"] = user_data.get("header_format")
3675
3699
 
3676
3700
  # Handle the column formula.
@@ -4507,7 +4531,7 @@ class Worksheet(xmlwriter.XMLwriter):
4507
4531
  header_orig = header
4508
4532
  header = header.replace("&[Picture]", "&G")
4509
4533
 
4510
- if len(header) > 255:
4534
+ if _utf16_len(header) > 255:
4511
4535
  warn("Header string cannot be longer than Excel's limit of 255 characters")
4512
4536
  return
4513
4537
 
@@ -4588,7 +4612,7 @@ class Worksheet(xmlwriter.XMLwriter):
4588
4612
  footer_orig = footer
4589
4613
  footer = footer.replace("&[Picture]", "&G")
4590
4614
 
4591
- if len(footer) > 255:
4615
+ if _utf16_len(footer) > 255:
4592
4616
  warn("Footer string cannot be longer than Excel's limit of 255 characters")
4593
4617
  return
4594
4618
 
@@ -5740,8 +5764,7 @@ class Worksheet(xmlwriter.XMLwriter):
5740
5764
 
5741
5765
  # Calculate the absolute x offset of the top-left vertex.
5742
5766
  if self.col_size_changed:
5743
- for col_id in range(col_start):
5744
- x_abs += self._size_col(col_id)
5767
+ x_abs += self._col_offset(col_start)
5745
5768
  else:
5746
5769
  # Optimization for when the column widths haven't changed.
5747
5770
  x_abs += self.default_col_width * col_start
@@ -5749,11 +5772,10 @@ class Worksheet(xmlwriter.XMLwriter):
5749
5772
  x_abs += x1
5750
5773
 
5751
5774
  # Calculate the absolute y offset of the top-left vertex.
5752
- if self.row_size_changed:
5753
- for row_id in range(row_start):
5754
- y_abs += self._size_row(row_id)
5775
+ if self.row_sizes:
5776
+ y_abs += self._row_offset(row_start)
5755
5777
  else:
5756
- # Optimization for when the row heights haven't changed.
5778
+ # Optimization for when no individual row heights have changed.
5757
5779
  y_abs += self.default_row_height * row_start
5758
5780
 
5759
5781
  y_abs += y1
@@ -5823,6 +5845,38 @@ class Worksheet(xmlwriter.XMLwriter):
5823
5845
 
5824
5846
  return self.default_row_height
5825
5847
 
5848
+ def _col_offset(self, col: int):
5849
+ # Get the absolute pixel offset of a column by summing the widths of
5850
+ # the columns before it. Objects are generally positioned in row/col
5851
+ # order so, to avoid re-summing from the first column for each object,
5852
+ # the sum restarts from the previously calculated column and offset.
5853
+ prev_col, offset = self.prev_col_offset
5854
+
5855
+ if col < prev_col:
5856
+ prev_col, offset = 0, 0
5857
+
5858
+ for col_id in range(prev_col, col):
5859
+ offset += self._size_col(col_id)
5860
+
5861
+ self.prev_col_offset = (col, offset)
5862
+
5863
+ return offset
5864
+
5865
+ def _row_offset(self, row: int):
5866
+ # Get the absolute pixel offset of a row by summing the heights of the
5867
+ # rows before it. See _col_offset() above.
5868
+ prev_row, offset = self.prev_row_offset
5869
+
5870
+ if row < prev_row:
5871
+ prev_row, offset = 0, 0
5872
+
5873
+ for row_id in range(prev_row, row):
5874
+ offset += self._size_row(row_id)
5875
+
5876
+ self.prev_row_offset = (row, offset)
5877
+
5878
+ return offset
5879
+
5826
5880
  def _pixels_to_height(self, pixels):
5827
5881
  # Convert the height of a cell from pixels to character units.
5828
5882
  return 0.75 * pixels
@@ -7591,9 +7645,8 @@ class Worksheet(xmlwriter.XMLwriter):
7591
7645
  try:
7592
7646
  float(formula)
7593
7647
  except ValueError:
7594
- # Not a number. Remove the formula '=' sign if it exists.
7595
- if formula.startswith("="):
7596
- formula = formula.lstrip("=")
7648
+ # Not a number, treat as a formula.
7649
+ formula = self._prepare_formula(formula, True)
7597
7650
 
7598
7651
  self._xml_data_element("formula1", formula)
7599
7652
 
@@ -7604,9 +7657,8 @@ class Worksheet(xmlwriter.XMLwriter):
7604
7657
  try:
7605
7658
  float(formula)
7606
7659
  except ValueError:
7607
- # Not a number. Remove the formula '=' sign if it exists.
7608
- if formula.startswith("="):
7609
- formula = formula.lstrip("=")
7660
+ # Not a number, treat as a formula.
7661
+ formula = self._prepare_formula(formula, True)
7610
7662
 
7611
7663
  self._xml_data_element("formula2", formula)
7612
7664
 
@@ -7737,9 +7789,8 @@ class Worksheet(xmlwriter.XMLwriter):
7737
7789
  try:
7738
7790
  float(formula)
7739
7791
  except ValueError:
7740
- # Not a number. Remove the formula '=' sign if it exists.
7741
- if formula.startswith("="):
7742
- formula = formula.lstrip("=")
7792
+ # Not a number, treat as a formula.
7793
+ formula = self._prepare_formula(formula, True)
7743
7794
 
7744
7795
  self._xml_data_element("formula", formula)
7745
7796
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: xlsxwriter
3
- Version: 3.3.0
3
+ Version: 3.3.1
4
4
  Summary: A Python module for creating Excel XLSX files.
5
5
  Author-email: John McNamara <jmcnamara@cpan.org>
6
6
  License-Expression: BSD-2-Clause
File without changes
File without changes
File without changes