Skip to content

Commit 04175bc

Browse files
committed
docs(pyumya): fix guide examples to match UmyaBook API
1 parent ce5063d commit 04175bc

8 files changed

Lines changed: 81 additions & 119 deletions

File tree

‎docs/pyumya/docs/guides/comments.md‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,14 @@ for c in comments:
1818
## Writing Comments
1919

2020
```python
21+
from excelbench_rust import UmyaBook
22+
2123
book = UmyaBook()
2224
book.add_sheet("Data")
2325

2426
book.write_cell_value("Data", "A1", {"type": "number", "value": 42.0})
25-
book.add_comment("Data", "A1", {
27+
book.add_comment("Data", {
28+
"cell": "A1",
2629
"text": "This value needs verification",
2730
"author": "Reviewer",
2831
})

‎docs/pyumya/docs/guides/conditional-formatting.md‎

Lines changed: 15 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -10,32 +10,32 @@ from excelbench_rust import UmyaBook
1010
book = UmyaBook.open("dashboard.xlsx")
1111
rules = book.read_conditional_formats("Sheet1")
1212
for r in rules:
13-
print(f"{r['ranges']}: {r['type']}")
14-
# ['A1:A100']: cellIs
15-
# ['B1:B100']: colorScale
13+
print(f"{r['range']}: {r['rule_type']}")
14+
# A1:A100: cellIs
15+
# B1:B100: colorScale
1616
```
1717

1818
## Writing Conditional Formats
1919

20-
### Cell Value Rules
21-
2220
```python
21+
from excelbench_rust import UmyaBook
22+
2323
book = UmyaBook()
2424
book.add_sheet("Sales")
2525

2626
# Highlight cells greater than 1000
2727
book.add_conditional_format("Sales", {
28-
"ranges": ["B2:B50"],
29-
"type": "cellIs",
28+
"range": "B2:B50",
29+
"rule_type": "cellIs",
3030
"operator": "greaterThan",
3131
"formula": "1000",
3232
"format": {"bg_color": "#C6EFCE", "font_color": "#006100"}, # green
3333
})
3434

3535
# Highlight cells below target
3636
book.add_conditional_format("Sales", {
37-
"ranges": ["B2:B50"],
38-
"type": "cellIs",
37+
"range": "B2:B50",
38+
"rule_type": "cellIs",
3939
"operator": "lessThan",
4040
"formula": "500",
4141
"format": {"bg_color": "#FFC7CE", "font_color": "#9C0006"}, # red
@@ -44,54 +44,12 @@ book.add_conditional_format("Sales", {
4444
book.save("output.xlsx")
4545
```
4646

47-
### Color Scales
48-
49-
```python
50-
# 2-color scale (red to green)
51-
book.add_conditional_format("Sales", {
52-
"ranges": ["C2:C50"],
53-
"type": "colorScale",
54-
"color_scale": {
55-
"min_color": "#FF0000",
56-
"max_color": "#00FF00",
57-
},
58-
})
59-
60-
# 3-color scale (red / yellow / green)
61-
book.add_conditional_format("Sales", {
62-
"ranges": ["D2:D50"],
63-
"type": "colorScale",
64-
"color_scale": {
65-
"min_color": "#FF0000",
66-
"mid_color": "#FFFF00",
67-
"max_color": "#00FF00",
68-
},
69-
})
70-
```
71-
72-
### Data Bars
73-
74-
```python
75-
book.add_conditional_format("Sales", {
76-
"ranges": ["E2:E50"],
77-
"type": "dataBar",
78-
"data_bar": {"color": "#638EC6"},
79-
})
80-
```
81-
8247
## Rule Types
8348

84-
| Type | Description | Key fields |
49+
| Type | Description | Notes |
8550
|------|-------------|-----------|
86-
| `cellIs` | Compare cell value | `operator`, `formula`, `format` |
87-
| `colorScale` | Gradient fill | `color_scale` with 2-3 colors |
88-
| `dataBar` | In-cell bar chart | `data_bar` with color |
89-
| `top10` | Top/bottom N | `rank`, `percent`, `bottom` |
90-
| `containsText` | Text matching | `text`, `format` |
91-
92-
## Rule Priority
93-
94-
!!! info "Evaluation order"
95-
When multiple rules apply to the same cell, rules are evaluated
96-
in the order they were added. The first matching rule determines
97-
the formatting. This matches Excel's "Stop if True" default behavior.
51+
| `cellIs` | Compare cell value | Writing supported (operator/formula + basic colors) |
52+
| `expression` | Formula-based condition | Writing supported (formula + basic colors) |
53+
| `colorScale` | Gradient fill | Currently read-only in the Python API |
54+
| `dataBar` | In-cell bar chart | Currently read-only in the Python API |
55+
| `iconSet` | Icon set | Currently read-only in the Python API |

‎docs/pyumya/docs/guides/data-validation.md‎

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,56 +10,48 @@ from excelbench_rust import UmyaBook
1010
book = UmyaBook.open("form.xlsx")
1111
validations = book.read_data_validations("Sheet1")
1212
for v in validations:
13-
print(f"{v['ranges']}: {v['type']} — {v.get('formula1', '')}")
14-
# ['B2:B100']: list — "Option A,Option B,Option C"
15-
# ['C2:C100']: whole — 1
13+
print(f"{v['range']}: {v['validation_type']} — {v.get('formula1')}")
14+
# B2:B100: list — Option A,Option B,Option C
15+
# C2:C100: whole — 1
1616
```
1717

1818
## Writing Validations
1919

20-
### Dropdown List
21-
2220
```python
21+
from excelbench_rust import UmyaBook
22+
2323
book = UmyaBook()
2424
book.add_sheet("Form")
2525

26-
# Create a dropdown list
2726
book.add_data_validation("Form", {
28-
"ranges": ["B2:B100"],
29-
"type": "list",
27+
"range": "B2:B100",
28+
"validation_type": "list",
3029
"formula1": "Option A,Option B,Option C",
31-
"show_dropdown": True,
30+
"allow_blank": True,
3231
})
3332

34-
book.save("output.xlsx")
35-
```
36-
37-
### Numeric Constraints
38-
39-
```python
4033
# Whole number between 1 and 100
4134
book.add_data_validation("Form", {
42-
"ranges": ["C2:C50"],
43-
"type": "whole",
35+
"range": "C2:C50",
36+
"validation_type": "whole",
4437
"operator": "between",
4538
"formula1": "1",
4639
"formula2": "100",
4740
"error_title": "Invalid Input",
48-
"error_message": "Enter a number between 1 and 100",
41+
"error": "Enter a number between 1 and 100",
42+
"show_error": True,
4943
})
50-
```
51-
52-
### Date Range
5344

54-
```python
5545
# Dates in 2026 only
5646
book.add_data_validation("Form", {
57-
"ranges": ["D2:D50"],
58-
"type": "date",
47+
"range": "D2:D50",
48+
"validation_type": "date",
5949
"operator": "between",
6050
"formula1": "2026-01-01",
6151
"formula2": "2026-12-31",
6252
})
53+
54+
book.save("output.xlsx")
6355
```
6456

6557
## Validation Types

‎docs/pyumya/docs/guides/freeze-panes.md‎

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,29 @@ from excelbench_rust import UmyaBook
99

1010
book = UmyaBook.open("dashboard.xlsx")
1111
panes = book.read_freeze_panes("Sheet1")
12-
print(panes) # {"row": 1, "column": 0} (top row frozen)
12+
print(panes) # {"mode": "freeze", "top_left_cell": "A2"} (top row frozen)
1313
```
1414

1515
## Writing Freeze Panes
1616

1717
```python
18+
from excelbench_rust import UmyaBook
19+
1820
book = UmyaBook()
1921
book.add_sheet("Data")
2022

21-
# Freeze top row (headers stay visible)
22-
book.set_freeze_panes("Data", {"row": 1, "column": 0})
23+
# Freeze panes are configured via:
24+
# - mode: "freeze" | "split"
25+
# - top_left_cell: e.g. "B2" (the first scrollable cell)
26+
27+
# To freeze the top row (headers stay visible):
28+
# book.set_freeze_panes("Data", {"mode": "freeze", "top_left_cell": "A2"})
2329

24-
# Freeze first column
25-
book.set_freeze_panes("Data", {"row": 0, "column": 1})
30+
# To freeze the first column:
31+
# book.set_freeze_panes("Data", {"mode": "freeze", "top_left_cell": "B1"})
2632

27-
# Freeze both (top-left corner stays fixed)
28-
book.set_freeze_panes("Data", {"row": 1, "column": 1})
33+
# To freeze both top row + first column:
34+
book.set_freeze_panes("Data", {"mode": "freeze", "top_left_cell": "B2"})
2935

3036
book.save("output.xlsx")
3137
```
@@ -34,12 +40,12 @@ book.save("output.xlsx")
3440

3541
| Use case | Settings | Excel equivalent |
3642
|----------|----------|-----------------|
37-
| Header row | `{"row": 1, "column": 0}` | View > Freeze Top Row |
38-
| First column | `{"row": 0, "column": 1}` | View > Freeze First Column |
39-
| Both | `{"row": 1, "column": 1}` | Select B2 > Freeze Panes |
40-
| Multi-row header | `{"row": 3, "column": 0}` | Select A4 > Freeze Panes |
43+
| Header row | `{"mode": "freeze", "top_left_cell": "A2"}` | View > Freeze Top Row |
44+
| First column | `{"mode": "freeze", "top_left_cell": "B1"}` | View > Freeze First Column |
45+
| Both | `{"mode": "freeze", "top_left_cell": "B2"}` | Select B2 > Freeze Panes |
46+
| Multi-row header | `{"mode": "freeze", "top_left_cell": "A4"}` | Select A4 > Freeze Panes |
4147

4248
!!! tip
43-
The `row` and `column` values specify the **split position** — rows above
44-
and columns to the left of that position are frozen. This matches the
45-
cell you'd select in Excel before clicking "Freeze Panes."
49+
`top_left_cell` is the first scrollable cell. Rows above and columns to
50+
the left of that cell become frozen. This matches the cell you'd select
51+
in Excel before clicking "Freeze Panes."

‎docs/pyumya/docs/guides/hyperlinks.md‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,31 @@ for link in links:
1818
## Writing Hyperlinks
1919

2020
```python
21+
from excelbench_rust import UmyaBook
22+
2123
book = UmyaBook()
2224
book.add_sheet("Links")
2325

2426
# Web URL
25-
book.write_cell_value("Links", "A1", {"type": "string", "value": "Visit Example"})
26-
book.add_hyperlink("Links", "A1", {
27+
book.add_hyperlink("Links", {
28+
"cell": "A1",
2729
"target": "https://example.com",
2830
"display": "Visit Example",
2931
})
3032

3133
# Email link
32-
book.add_hyperlink("Links", "A2", {
34+
book.add_hyperlink("Links", {
35+
"cell": "A2",
3336
"target": "mailto:support@example.com",
3437
"display": "Email Support",
3538
})
3639

3740
# Internal reference (another sheet)
38-
book.add_hyperlink("Links", "A3", {
41+
book.add_hyperlink("Links", {
42+
"cell": "A3",
3943
"target": "#Summary!A1",
4044
"display": "Go to Summary",
45+
"internal": True,
4146
})
4247

4348
book.save("output.xlsx")

‎docs/pyumya/docs/guides/images.md‎

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,37 +10,32 @@ from excelbench_rust import UmyaBook
1010
book = UmyaBook.open("report.xlsx")
1111
images = book.read_images("Sheet1")
1212
for img in images:
13-
print(f"Cell {img['cell']}: {img['format']} ({len(img['data'])} bytes)")
14-
# Cell A1: png (24576 bytes)
13+
print(f"Image at {img['cell']}: anchor={img['anchor']}, offset={img['offset']}")
14+
# Image at A1: anchor=oneCell, offset=[0, 0]
1515
```
1616

1717
## Writing Images
1818

1919
```python
20-
from pathlib import Path
2120
from excelbench_rust import UmyaBook
2221

2322
book = UmyaBook()
2423
book.add_sheet("Report")
2524

26-
# Embed an image from file
27-
book.add_image("Report", "B2", {
28-
"data": Path("logo.png").read_bytes(),
29-
"format": "png",
25+
# Embed an image by file path
26+
book.add_image("Report", {
27+
"path": "logo.png",
28+
"cell": "B2",
3029
})
3130

3231
book.save("output.xlsx")
3332
```
3433

35-
## Supported Formats
34+
## Formats
3635

37-
| Format | Extension | Read | Write |
38-
|--------|-----------|:----:|:-----:|
39-
| PNG | `.png` | Yes | Yes |
40-
| JPEG | `.jpg`, `.jpeg` | Yes | Yes |
41-
| GIF | `.gif` | Yes | Yes |
42-
| BMP | `.bmp` | Yes | Yes |
43-
| EMF | `.emf` | Yes | Yes |
36+
The Python API currently exposes image **anchors** (positioning) but does not
37+
expose image bytes or a detected format on read. For writes, provide a file
38+
path (e.g. PNG/JPEG).
4439

4540
## Image Positioning
4641

‎docs/pyumya/docs/guides/merged-cells.md‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# Merged Cells
22

3-
Merge and unmerge cell ranges in Excel workbooks.
3+
Merge cell ranges in Excel workbooks.
44

55
## Reading Merged Ranges
66

77
```python
88
from excelbench_rust import UmyaBook
99

1010
book = UmyaBook.open("report.xlsx")
11-
merged = book.read_merged_cells("Sheet1")
11+
merged = book.read_merged_ranges("Sheet1")
1212
print(merged) # ["A1:D1", "B3:B5"]
1313
```
1414

@@ -40,3 +40,8 @@ book.save("output.xlsx")
4040
- Merging a range that overlaps an existing merge will raise an error in Excel
4141
- Single-cell "merges" (e.g., `"A1:A1"`) are valid but have no visual effect
4242
- Merged cells with borders apply the border to the entire merged region
43+
44+
!!! note "Unmerge"
45+
Unmerging is not currently exposed in the Python API. If you need it, open
46+
an issue and include the exact Excel behavior you want (preserve top-left
47+
value, how to handle formatting, etc.).

‎docs/pyumya/mkdocs.yml‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@ extra:
6565

6666
nav:
6767
- Home: index.md
68-
- Getting Started:
69-
- Installation: index.md
7068
- Guides:
7169
- Merged Cells: guides/merged-cells.md
7270
- Comments: guides/comments.md

0 commit comments

Comments
 (0)