XlsxWriter 3.3.1__tar.gz → 3.3.2__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.
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/Changes +36 -0
- {xlsxwriter-3.3.1/xlsxwriter.egg-info → xlsxwriter-3.3.2}/PKG-INFO +1 -1
- xlsxwriter-3.3.2/examples/theme_custom.py +36 -0
- xlsxwriter-3.3.2/examples/theme_excel_2023.py +20 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/pyproject.toml +1 -1
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/xlsxwriter/__init__.py +1 -1
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/xlsxwriter/core.py +7 -6
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/xlsxwriter/format.py +1 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/xlsxwriter/utility.py +9 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/xlsxwriter/workbook.py +55 -37
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/xlsxwriter/worksheet.py +234 -223
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2/xlsxwriter.egg-info}/PKG-INFO +1 -1
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/xlsxwriter.egg-info/SOURCES.txt +2 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/LICENSE.txt +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/MANIFEST.in +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/README.rst +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/array_formula.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/autofilter.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/autofilter_data.txt +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/autofit.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/autofit_manually.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/background.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/cell_indentation.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/chart.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/chart_area.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/chart_bar.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/chart_clustered.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/chart_column.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/chart_combined.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/chart_data_labels.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/chart_data_table.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/chart_data_tools.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/chart_date_axis.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/chart_doughnut.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/chart_gauge.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/chart_gradient.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/chart_line.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/chart_pareto.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/chart_pattern.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/chart_pie.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/chart_radar.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/chart_scatter.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/chart_secondary_axis.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/chart_stock.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/chart_styles.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/chartsheet.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/check_close.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/checkbox.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/colors.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/comments1.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/comments2.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/conditional_format.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/context_manager.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/data_validate.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/datetimes.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/defined_name.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/demo.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/diagonal_border.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/django_simple.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/doc_properties.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/dynamic_arrays.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/embedded_images.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/headers_footers.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/hello_world.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/hide_row_col.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/hide_sheet.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/http_server.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/hyperlink.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/ignore_errors.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/images.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/images_bytesio.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/inheritance1.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/inheritance2.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/lambda.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/macros.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/merge1.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/merge_rich_string.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/outline.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/outline_collapsed.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/pandas_autofilter.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/pandas_chart.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/pandas_chart_columns.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/pandas_chart_line.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/pandas_column_formats.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/pandas_conditional_format.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/pandas_datetime.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/pandas_header_format.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/pandas_multiple.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/pandas_percentage.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/pandas_positioning.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/pandas_simple.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/pandas_table.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/panes.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/polars_chart.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/polars_checkbox.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/polars_conditional_format.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/polars_format_custom.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/polars_format_default.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/polars_multiple.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/polars_positioning.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/polars_simple.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/polars_sparklines.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/polars_xlsxwriter.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/rich_strings.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/right_to_left.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/sensitivity_label.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/sparklines1.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/sparklines2.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/tab_colors.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/tables.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/text_indent.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/textbox.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/tutorial1.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/tutorial2.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/tutorial3.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/unicode.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/unicode_polish_utf8.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/unicode_polish_utf8.txt +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/unicode_shift_jis.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/unicode_shift_jis.txt +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/user_types1.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/user_types2.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/user_types3.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/vbaProject.bin +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/vba_extract.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/watermark.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/examples/worksheet_protection.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/setup.cfg +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/xlsxwriter/app.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/xlsxwriter/chart.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/xlsxwriter/chart_area.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/xlsxwriter/chart_bar.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/xlsxwriter/chart_column.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/xlsxwriter/chart_doughnut.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/xlsxwriter/chart_line.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/xlsxwriter/chart_pie.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/xlsxwriter/chart_radar.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/xlsxwriter/chart_scatter.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/xlsxwriter/chart_stock.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/xlsxwriter/chart_title.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/xlsxwriter/chartsheet.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/xlsxwriter/color.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/xlsxwriter/comments.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/xlsxwriter/contenttypes.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/xlsxwriter/custom.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/xlsxwriter/drawing.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/xlsxwriter/exceptions.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/xlsxwriter/feature_property_bag.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/xlsxwriter/image.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/xlsxwriter/metadata.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/xlsxwriter/packager.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/xlsxwriter/relationships.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/xlsxwriter/rich_value.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/xlsxwriter/rich_value_rel.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/xlsxwriter/rich_value_structure.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/xlsxwriter/rich_value_types.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/xlsxwriter/shape.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/xlsxwriter/sharedstrings.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/xlsxwriter/styles.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/xlsxwriter/table.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/xlsxwriter/theme.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/xlsxwriter/url.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/xlsxwriter/vml.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/xlsxwriter/xmlwriter.py +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/xlsxwriter.egg-info/dependency_links.txt +0 -0
- {xlsxwriter-3.3.1 → xlsxwriter-3.3.2}/xlsxwriter.egg-info/top_level.txt +0 -0
|
@@ -1,4 +1,40 @@
|
|
|
1
1
|
|
|
2
|
+
Release 3.3.2 - November 19 2026
|
|
3
|
+
--------------------------------
|
|
4
|
+
|
|
5
|
+
* Added documentation and examples for the ``excel_2023_theme``,
|
|
6
|
+
``default_format_properties``, ``default_row_height`` and
|
|
7
|
+
``default_column_width`` Workbook options. See :ref:`ex_theme_excel_2023`
|
|
8
|
+
and :ref:`ex_theme_custom`.
|
|
9
|
+
|
|
10
|
+
:feature:`1163`.
|
|
11
|
+
|
|
12
|
+
* Fixed issue where a ``created`` date in :func:`set_properties` was replaced
|
|
13
|
+
with the current time if it was a ``datetime.date``. Also allow a
|
|
14
|
+
``datetime.date`` in :func:`set_custom_property`.
|
|
15
|
+
|
|
16
|
+
:issue:`1225`.
|
|
17
|
+
|
|
18
|
+
* Fixed issue where timezone aware datetimes in :func:`set_properties` and
|
|
19
|
+
:func:`set_custom_property` weren't converted to UTC.
|
|
20
|
+
|
|
21
|
+
:issue:`1227`.
|
|
22
|
+
|
|
23
|
+
* Fixed issue where a rejected :func:`add_table`, :func:`merge_range` or
|
|
24
|
+
:func:`autofilter` could leave reserved cells that caused a later
|
|
25
|
+
``OverlappingRange`` exception.
|
|
26
|
+
|
|
27
|
+
:issue:`1229`.
|
|
28
|
+
|
|
29
|
+
* Improved the performance of :func:`write_formula` and other methods that
|
|
30
|
+
handle formulas.
|
|
31
|
+
|
|
32
|
+
:issue:`1228`.
|
|
33
|
+
|
|
34
|
+
* Fixed issue where function names in formula string literals, and names such
|
|
35
|
+
as ``MYSINGLE()``, were treated as "future" functions.
|
|
36
|
+
|
|
37
|
+
|
|
2
38
|
Release 3.3.1 - October 28 2026
|
|
3
39
|
-------------------------------
|
|
4
40
|
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
##############################################################################
|
|
2
|
+
#
|
|
3
|
+
# An example of changing the default theme for a workbook to a user supplied
|
|
4
|
+
# custom theme using XlsxWriter.
|
|
5
|
+
#
|
|
6
|
+
# SPDX-License-Identifier: BSD-2-Clause
|
|
7
|
+
#
|
|
8
|
+
# Copyright (c) 2013-2026, John McNamara, jmcnamara@cpan.org
|
|
9
|
+
#
|
|
10
|
+
import xlsxwriter
|
|
11
|
+
|
|
12
|
+
# Set the default format to match the custom theme. Note, the font scheme is set
|
|
13
|
+
# to "minor" to indicate that the font is part of the theme.
|
|
14
|
+
workbook = xlsxwriter.Workbook(
|
|
15
|
+
"theme_custom.xlsx",
|
|
16
|
+
{
|
|
17
|
+
"default_format_properties": {
|
|
18
|
+
"font_name": "Arial",
|
|
19
|
+
"font_size": 11,
|
|
20
|
+
"font_scheme": "minor",
|
|
21
|
+
},
|
|
22
|
+
"default_row_height": 19,
|
|
23
|
+
"default_column_width": 72,
|
|
24
|
+
},
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
# Add a custom theme to the workbook. This can be a .thmx file, an .xlsx file,
|
|
28
|
+
# or a theme1.xml file extracted from an unzipped xlsx file.
|
|
29
|
+
workbook.use_custom_theme("Technic.thmx")
|
|
30
|
+
|
|
31
|
+
worksheet = workbook.add_worksheet()
|
|
32
|
+
|
|
33
|
+
# Write some text to demonstrate the changed theme.
|
|
34
|
+
worksheet.write("A1", "Hello")
|
|
35
|
+
|
|
36
|
+
workbook.close()
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
##############################################################################
|
|
2
|
+
#
|
|
3
|
+
# An example of changing the default theme for a workbook to the Excel 2023
|
|
4
|
+
# Office/Aptos theme using XlsxWriter.
|
|
5
|
+
#
|
|
6
|
+
# SPDX-License-Identifier: BSD-2-Clause
|
|
7
|
+
#
|
|
8
|
+
# Copyright (c) 2013-2026, John McNamara, jmcnamara@cpan.org
|
|
9
|
+
#
|
|
10
|
+
import xlsxwriter
|
|
11
|
+
|
|
12
|
+
# Use the Excel 2023 Office/Aptos theme in the workbook.
|
|
13
|
+
workbook = xlsxwriter.Workbook("theme_excel_2023.xlsx", {"excel_2023_theme": True})
|
|
14
|
+
|
|
15
|
+
worksheet = workbook.add_worksheet()
|
|
16
|
+
|
|
17
|
+
# Write some text to demonstrate the changed theme.
|
|
18
|
+
worksheet.write("A1", "Hello")
|
|
19
|
+
|
|
20
|
+
workbook.close()
|
|
@@ -7,10 +7,11 @@
|
|
|
7
7
|
# Copyright (c) 2013-2026, John McNamara, jmcnamara@cpan.org
|
|
8
8
|
#
|
|
9
9
|
|
|
10
|
-
from datetime import datetime, timezone
|
|
10
|
+
from datetime import date, datetime, timezone
|
|
11
11
|
from typing import Dict, Union
|
|
12
12
|
|
|
13
13
|
from xlsxwriter import xmlwriter
|
|
14
|
+
from xlsxwriter.utility import _datetime_to_w3cdtf
|
|
14
15
|
|
|
15
16
|
|
|
16
17
|
class Core(xmlwriter.XMLwriter):
|
|
@@ -47,11 +48,11 @@ class Core(xmlwriter.XMLwriter):
|
|
|
47
48
|
# Assemble and write the XML file.
|
|
48
49
|
|
|
49
50
|
# Set the creation date for the file.
|
|
50
|
-
|
|
51
|
-
if not isinstance(
|
|
52
|
-
|
|
51
|
+
created = self.properties.get("created")
|
|
52
|
+
if not isinstance(created, date):
|
|
53
|
+
created = datetime.now(timezone.utc)
|
|
53
54
|
|
|
54
|
-
self.iso_date =
|
|
55
|
+
self.iso_date = _datetime_to_w3cdtf(created)
|
|
55
56
|
|
|
56
57
|
# Write the XML declaration.
|
|
57
58
|
self._xml_declaration()
|
|
@@ -73,7 +74,7 @@ class Core(xmlwriter.XMLwriter):
|
|
|
73
74
|
# Close the file.
|
|
74
75
|
self._xml_close()
|
|
75
76
|
|
|
76
|
-
def _set_properties(self, properties: Dict[str, Union[str,
|
|
77
|
+
def _set_properties(self, properties: Dict[str, Union[str, date]]) -> None:
|
|
77
78
|
# Set the document properties.
|
|
78
79
|
self.properties = properties
|
|
79
80
|
|
|
@@ -954,6 +954,15 @@ def _preserve_whitespace(string: str) -> Optional[re.Match]:
|
|
|
954
954
|
return RE_LEADING_WHITESPACE.search(string) or RE_TRAILING_WHITESPACE.search(string)
|
|
955
955
|
|
|
956
956
|
|
|
957
|
+
def _datetime_to_w3cdtf(date: datetime.date) -> str:
|
|
958
|
+
# Convert a date or datetime to the UTC string used in the document
|
|
959
|
+
# properties. Timezone aware datetimes are converted to UTC.
|
|
960
|
+
if isinstance(date, datetime.datetime) and date.tzinfo is not None:
|
|
961
|
+
date = date.astimezone(datetime.timezone.utc)
|
|
962
|
+
|
|
963
|
+
return date.strftime("%Y-%m-%dT%H:%M:%SZ")
|
|
964
|
+
|
|
965
|
+
|
|
957
966
|
def _utf16_len(string: str) -> int:
|
|
958
967
|
# Get the length of a string in UTF-16 units. Excel's string length limits
|
|
959
968
|
# are in UTF-16 units, so characters above U+FFFF, such as emojis, count as 2.
|
|
@@ -14,7 +14,7 @@ import re
|
|
|
14
14
|
import time
|
|
15
15
|
import warnings
|
|
16
16
|
import zipfile
|
|
17
|
-
from datetime import
|
|
17
|
+
from datetime import date
|
|
18
18
|
from decimal import Decimal
|
|
19
19
|
from fractions import Fraction
|
|
20
20
|
from io import StringIO
|
|
@@ -46,7 +46,12 @@ 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
|
|
49
|
+
from xlsxwriter.utility import (
|
|
50
|
+
_datetime_to_w3cdtf,
|
|
51
|
+
_has_invalid_name_chars,
|
|
52
|
+
_utf16_len,
|
|
53
|
+
xl_cell_to_rowcol,
|
|
54
|
+
)
|
|
50
55
|
from xlsxwriter.worksheet import Worksheet
|
|
51
56
|
|
|
52
57
|
|
|
@@ -99,6 +104,7 @@ class Workbook(xmlwriter.XMLwriter):
|
|
|
99
104
|
self.default_format_properties = options.get(
|
|
100
105
|
"default_format_properties", {"font_name": "Calibri", "font_size": 11}
|
|
101
106
|
)
|
|
107
|
+
self.default_format = None
|
|
102
108
|
|
|
103
109
|
self.max_url_length = options.get("max_url_length", 2079)
|
|
104
110
|
if self.max_url_length < 255:
|
|
@@ -172,47 +178,35 @@ class Workbook(xmlwriter.XMLwriter):
|
|
|
172
178
|
|
|
173
179
|
# Add the default cell format.
|
|
174
180
|
if self.excel_2023_theme:
|
|
181
|
+
self.default_theme_version = "202300"
|
|
182
|
+
self.theme_xml: str = THEME_XML_2023
|
|
183
|
+
|
|
175
184
|
format_properties = {
|
|
176
185
|
"font_name": "Aptos Narrow",
|
|
177
186
|
"font_size": 11,
|
|
178
187
|
"font_scheme": "minor",
|
|
179
188
|
}
|
|
180
|
-
self.
|
|
181
|
-
self.default_col_width = 64
|
|
182
|
-
self.default_row_height = 20
|
|
183
|
-
self.default_theme_version = "202300"
|
|
184
|
-
self.theme_xml: str = THEME_XML_2023
|
|
185
|
-
|
|
186
|
-
format_properties["xf_index"] = 0
|
|
187
|
-
self.add_format(format_properties)
|
|
189
|
+
self._set_default_format(format_properties, 20, 64)
|
|
188
190
|
|
|
189
191
|
elif self.excel2003_style:
|
|
190
192
|
# This is a deprecated workaround for Excel 2003 style default format.
|
|
191
193
|
format_properties = {
|
|
192
194
|
"font_name": "Arial",
|
|
193
195
|
"font_size": 10,
|
|
194
|
-
"font_family": 0,
|
|
195
196
|
"font_scheme": False,
|
|
196
197
|
"theme": -1,
|
|
197
198
|
}
|
|
198
|
-
|
|
199
|
-
|
|
199
|
+
self._set_default_format(
|
|
200
|
+
format_properties, self.default_row_height, self.default_col_width
|
|
201
|
+
)
|
|
202
|
+
self.default_format.set_font_family(0)
|
|
200
203
|
|
|
201
|
-
self.default_format_properties = {
|
|
202
|
-
"font_name": "Arial",
|
|
203
|
-
"font_size": 10,
|
|
204
|
-
"font_scheme": False,
|
|
205
|
-
"theme": -1,
|
|
206
|
-
}
|
|
207
204
|
else:
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
self.default_format_properties["theme_font_name"] = (
|
|
214
|
-
self.default_format_properties.get("font_name", "Calibri")
|
|
215
|
-
)
|
|
205
|
+
self._set_default_format(
|
|
206
|
+
self.default_format_properties,
|
|
207
|
+
self.default_row_height,
|
|
208
|
+
self.default_col_width,
|
|
209
|
+
)
|
|
216
210
|
|
|
217
211
|
# Add a default URL format.
|
|
218
212
|
format_properties = self.default_format_properties.copy()
|
|
@@ -226,10 +220,6 @@ class Workbook(xmlwriter.XMLwriter):
|
|
|
226
220
|
{"num_format": self.default_date_format}
|
|
227
221
|
)
|
|
228
222
|
|
|
229
|
-
self.max_digit_width, self.cell_padding, self.max_col_width = (
|
|
230
|
-
self._default_column_metrics(self.default_col_width)
|
|
231
|
-
)
|
|
232
|
-
|
|
233
223
|
def __enter__(self):
|
|
234
224
|
"""Return self object to use with "with" statement."""
|
|
235
225
|
return self
|
|
@@ -291,6 +281,11 @@ class Workbook(xmlwriter.XMLwriter):
|
|
|
291
281
|
if properties:
|
|
292
282
|
format_properties.update(properties)
|
|
293
283
|
|
|
284
|
+
# Set a user font name after any default font scheme, so that it
|
|
285
|
+
# can turn off the theme scheme.
|
|
286
|
+
if "font_name" in properties and "font_scheme" not in properties:
|
|
287
|
+
format_properties["font_name"] = format_properties.pop("font_name")
|
|
288
|
+
|
|
294
289
|
xf_format = Format(
|
|
295
290
|
format_properties, self.xf_format_indices, self.dxf_format_indices
|
|
296
291
|
)
|
|
@@ -554,7 +549,7 @@ class Workbook(xmlwriter.XMLwriter):
|
|
|
554
549
|
def set_custom_property(
|
|
555
550
|
self,
|
|
556
551
|
name: str,
|
|
557
|
-
value: Union[bool,
|
|
552
|
+
value: Union[bool, date, float, Decimal, Fraction, Any],
|
|
558
553
|
property_type: Optional[
|
|
559
554
|
Literal["bool", "date", "number", "number_int", "text"]
|
|
560
555
|
] = None,
|
|
@@ -582,7 +577,7 @@ class Workbook(xmlwriter.XMLwriter):
|
|
|
582
577
|
# Determine the property type from the Python type.
|
|
583
578
|
if isinstance(value, bool):
|
|
584
579
|
property_type = "bool"
|
|
585
|
-
elif isinstance(value,
|
|
580
|
+
elif isinstance(value, date):
|
|
586
581
|
property_type = "date"
|
|
587
582
|
elif isinstance(value, int):
|
|
588
583
|
property_type = "number_int"
|
|
@@ -596,7 +591,7 @@ class Workbook(xmlwriter.XMLwriter):
|
|
|
596
591
|
value = str(value).lower()
|
|
597
592
|
|
|
598
593
|
if property_type == "date":
|
|
599
|
-
value = value
|
|
594
|
+
value = _datetime_to_w3cdtf(value)
|
|
600
595
|
|
|
601
596
|
if property_type in ("number", "number_int"):
|
|
602
597
|
value = str(value)
|
|
@@ -961,6 +956,7 @@ class Workbook(xmlwriter.XMLwriter):
|
|
|
961
956
|
"nan_inf_to_errors": self.nan_inf_to_errors,
|
|
962
957
|
"default_date_format": self.default_date_format,
|
|
963
958
|
"default_url_format": self.default_url_format,
|
|
959
|
+
"default_format": self.default_format,
|
|
964
960
|
"workbook_add_format": self.add_format,
|
|
965
961
|
"excel2003_style": self.excel2003_style,
|
|
966
962
|
"remove_timezone": self.remove_timezone,
|
|
@@ -1698,7 +1694,30 @@ class Workbook(xmlwriter.XMLwriter):
|
|
|
1698
1694
|
# This allows the default packager to be over-ridden.
|
|
1699
1695
|
return Packager()
|
|
1700
1696
|
|
|
1701
|
-
def
|
|
1697
|
+
def _set_default_format(
|
|
1698
|
+
self, properties: Dict[str, Any], row_height: int, col_width: int
|
|
1699
|
+
) -> None:
|
|
1700
|
+
# Set the default cell format and the row/column dimensions that go
|
|
1701
|
+
# with it.
|
|
1702
|
+
metrics = self._default_column_metrics(col_width)
|
|
1703
|
+
if metrics is None:
|
|
1704
|
+
warn(f"Unsupported default_column_width '{col_width}'. Using 64 pixels.")
|
|
1705
|
+
col_width = 64
|
|
1706
|
+
metrics = self._default_column_metrics(col_width)
|
|
1707
|
+
|
|
1708
|
+
self.max_digit_width, self.cell_padding, self.max_col_width = metrics
|
|
1709
|
+
self.default_col_width = col_width
|
|
1710
|
+
self.default_row_height = row_height
|
|
1711
|
+
|
|
1712
|
+
self.default_format_properties = properties.copy()
|
|
1713
|
+
self.default_format = self.add_format({"xf_index": 0})
|
|
1714
|
+
|
|
1715
|
+
# Store the theme font name to cell format properties.
|
|
1716
|
+
self.default_format_properties["theme_font_name"] = properties.get(
|
|
1717
|
+
"font_name", "Calibri"
|
|
1718
|
+
)
|
|
1719
|
+
|
|
1720
|
+
def _default_column_metrics(self, width: int) -> Optional[Tuple[int, int, int]]:
|
|
1702
1721
|
# Get default font metrics for a default column width.
|
|
1703
1722
|
#
|
|
1704
1723
|
# This function returns the font metrics (max_digit_width, padding,
|
|
@@ -1721,8 +1740,7 @@ class Workbook(xmlwriter.XMLwriter):
|
|
|
1721
1740
|
elif width == 120:
|
|
1722
1741
|
metrics = (13, 9, 3323)
|
|
1723
1742
|
else:
|
|
1724
|
-
|
|
1725
|
-
metrics = (7, 5, 1790)
|
|
1743
|
+
metrics = None
|
|
1726
1744
|
|
|
1727
1745
|
return metrics
|
|
1728
1746
|
|