Skip to content

Docs for data #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion en/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 3 additions & 0 deletions en/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
72 changes: 72 additions & 0 deletions en/data.md
Original file line number Diff line number Diff line change
@@ -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.