From bd2b4d71257d8bd2e5f415a603d6b1af05a1cf5b Mon Sep 17 00:00:00 2001 From: Tammy Date: Fri, 25 Jul 2025 10:53:22 +0000 Subject: [PATCH] Docs for data --- en/README.md | 2 +- en/SUMMARY.md | 3 +++ en/data.md | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 en/data.md diff --git a/en/README.md b/en/README.md index 25fc278..331983e 100644 --- a/en/README.md +++ b/en/README.md @@ -9,7 +9,7 @@ Excelize for Python is a Python port of Go [Excelize](https://github.com/xuri/ex - PyPI: [pypi.org/project/excelize](https://pypi.org/project/excelize) - Licenses: [BSD 3-Clause](https://opensource.org/licenses/BSD-3-Clause) - Last version: [v0.0.4](https://github.com/xuri/excelize-py/releases/latest) -- Document update time: July 23, 2025 +- Document update time: July 26, 2025 ## Project mission diff --git a/en/SUMMARY.md b/en/SUMMARY.md index e4916e8..d684244 100644 --- a/en/SUMMARY.md +++ b/en/SUMMARY.md @@ -120,3 +120,6 @@ * [Write sheet row in stream](stream.md#SetRow) * [Add table in stream](stream.md#AddTable) * [Insert page break in stream](stream.md#InsertPageBreak) +* [Data](data.md) + * [Add slicer](data.md#AddSlicer) + * [Delete slicer](data.md#DeleteSlicer) diff --git a/en/data.md b/en/data.md new file mode 100644 index 0000000..84f0178 --- /dev/null +++ b/en/data.md @@ -0,0 +1,72 @@ +# Data + +## Add slicer {#AddSlicer} + +`SlicerOptions` represents the settings of the slicer. + +```python +class SlicerOptions: + name: str = "" + cell: str = "" + table_sheet: str = "" + table_name: str = "" + caption: str = "" + macro: str = "" + width: int = 0 + height: int = 0 + display_header: Optional[bool] = None + item_desc: bool = False + format: GraphicOptions = GraphicOptions +``` + +`name` specifies the slicer name, should be an existing field name of the given table or pivot table, this setting is required. + +`table` specifies the name of the table or pivot table, this setting is required. + +`cell` specifies the left top cell coordinates the position for inserting the slicer, this setting is required. + +`caption` specifies the caption of the slicer, this setting is optional. + +`macro` used for set macro for the slicer, the workbook extension should be XLSM or XLTM. + +`width` specifies the width of the slicer, this setting is optional. + +`height` specifies the height of the slicer, this setting is optional. + +`display_header` specifies if display header of the slicer, this setting is optional, the default setting is display. + +`item_desc` specifies descending (Z-A) item sorting, this setting is optional, and the default setting is `False` (represents ascending). + +`format` specifies the format of the slicer, this setting is optional. + +```python +def add_slicer(sheet: str, opts: SlicerOptions) -> None +``` + +Inserts a slicer by giving the worksheet name and slicer settings. For example, insert a slicer on the `Sheet1!E1` with field `Column1` for the table named `Table1`: + +```python +try: + f.add_slicer( + "Sheet1", + excelize.SlicerOptions( + name="Column1", + cell="E1", + table_sheet="Sheet1", + table_name="Table1", + caption="Column1", + width=200, + height=200, + ), + ) +except RuntimeError as err: + print(err) +``` + +## Delete slicer {#DeleteSlicer} + +```python +def delete_slicer(name: str) -> None +``` + +Delete a slicer by a given slicer name.