Skip to content

Commit 26d0e53

Browse files
committed
Docs for slicer
1 parent c001514 commit 26d0e53

File tree

3 files changed

+76
-1
lines changed

3 files changed

+76
-1
lines changed

en/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Excelize for Python is a Python port of Go [Excelize](https://github.com/xuri/ex
99
- PyPI: [pypi.org/project/excelize](https://pypi.org/project/excelize)
1010
- Licenses: [BSD 3-Clause](https://opensource.org/licenses/BSD-3-Clause)
1111
- Last version: [v0.0.4](https://github.com/xuri/excelize-py/releases/latest)
12-
- Document update time: July 23, 2025
12+
- Document update time: August 18, 2025
1313

1414
## Project mission
1515

en/SUMMARY.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,3 +120,6 @@
120120
* [Write sheet row in stream](stream.md#SetRow)
121121
* [Add table in stream](stream.md#AddTable)
122122
* [Insert page break in stream](stream.md#InsertPageBreak)
123+
* [Data](data.md)
124+
* [Add slicer](data.md#AddSlicer)
125+
* [Delete slicer](data.md#DeleteSlicer)

en/data.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# Data
2+
3+
## Add slicer {#AddSlicer}
4+
5+
`SlicerOptions` represents the settings of the slicer.
6+
7+
```python
8+
class SlicerOptions:
9+
name: str = ""
10+
cell: str = ""
11+
table_sheet: str = ""
12+
table_name: str = ""
13+
caption: str = ""
14+
macro: str = ""
15+
width: int = 0
16+
height: int = 0
17+
display_header: Optional[bool] = None
18+
item_desc: bool = False
19+
format: GraphicOptions = GraphicOptions
20+
```
21+
22+
`name` specifies the slicer name, should be an existing field name of the given table or pivot table, this setting is required.
23+
24+
`table` specifies the name of the table or pivot table, this setting is required.
25+
26+
`cell` specifies the left top cell coordinates the position for inserting the slicer, this setting is required.
27+
28+
`caption` specifies the caption of the slicer, this setting is optional.
29+
30+
`macro` used for set macro for the slicer, the workbook extension should be XLSM or XLTM.
31+
32+
`width` specifies the width of the slicer, this setting is optional.
33+
34+
`height` specifies the height of the slicer, this setting is optional.
35+
36+
`display_header` specifies if display header of the slicer, this setting is optional, the default setting is display.
37+
38+
`item_desc` specifies descending (Z-A) item sorting, this setting is optional, and the default setting is `false` (represents ascending).
39+
40+
`format` specifies the format of the slicer, this setting is optional.
41+
42+
```python
43+
def add_slicer(self, sheet: str, opts: SlicerOptions) -> None
44+
```
45+
46+
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`:
47+
48+
```python
49+
try:
50+
f.add_slicer(
51+
"Sheet1",
52+
excelize.SlicerOptions(
53+
name="Column1",
54+
cell="E1",
55+
table_sheet="Sheet1",
56+
table_name="Table1",
57+
caption="Column1",
58+
width=200,
59+
height=200,
60+
),
61+
)
62+
except (RuntimeError, TypeError) as err:
63+
print(err)
64+
```
65+
66+
## Delete slicer {#DeleteSlicer}
67+
68+
```python
69+
def delete_slicer(self, name: str) -> None
70+
```
71+
72+
Delete a slicer by a given slicer name.

0 commit comments

Comments
 (0)