From 878affabe4434168ec8cdc2e4810e704b114a38b Mon Sep 17 00:00:00 2001 From: John McNamara Date: Mon, 9 Oct 2023 17:35:53 +0100 Subject: [PATCH] table: fix escaping of future funtions Issue #1015 --- xlsxwriter/test/comparison/test_table35.py | 59 ++++++++++++++++++ .../test/comparison/xlsx_files/table35.xlsx | Bin 0 -> 7308 bytes xlsxwriter/worksheet.py | 7 ++- 3 files changed, 64 insertions(+), 2 deletions(-) create mode 100644 xlsxwriter/test/comparison/test_table35.py create mode 100644 xlsxwriter/test/comparison/xlsx_files/table35.xlsx diff --git a/xlsxwriter/test/comparison/test_table35.py b/xlsxwriter/test/comparison/test_table35.py new file mode 100644 index 000000000..c049b5d00 --- /dev/null +++ b/xlsxwriter/test/comparison/test_table35.py @@ -0,0 +1,59 @@ +############################################################################### +# +# Tests for XlsxWriter. +# +# SPDX-License-Identifier: BSD-2-Clause +# Copyright (c), 2013-2023, John McNamara, jmcnamara@cpan.org +# + +from ..excel_comparison_test import ExcelComparisonTest +from ...workbook import Workbook + + +class TestCompareXLSXFiles(ExcelComparisonTest): + """ + Test file created by XlsxWriter against a file created by Excel. + + """ + + def setUp(self): + self.set_filename("table35.xlsx") + + self.ignore_files = [ + "xl/calcChain.xml", + "[Content_Types].xml", + "xl/_rels/workbook.xml.rels", + ] + + def test_create_file(self): + """Test the creation of a simple XlsxWriter file with tables.""" + + workbook = Workbook(self.got_filename) + worksheet = workbook.add_worksheet() + format1 = workbook.add_format({"num_format": "0.0000"}) + + data = [ + ["Foo", 1234, 0, 4321], + ["Bar", 1256, 0, 4320], + ["Baz", 2234, 0, 4332], + ["Bop", 1324, 0, 4333], + ] + + worksheet.set_column("C:F", 10.288) + + worksheet.add_table( + "C2:F6", + { + "data": data, + "columns": [ + {}, + {}, + {}, + {"formula": "BASE(0,2)", "format": format1}, + ], + }, + ) + + workbook.close() + + self.assertExcelEqual() diff --git a/xlsxwriter/test/comparison/xlsx_files/table35.xlsx b/xlsxwriter/test/comparison/xlsx_files/table35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