exstruct 0.2.51__tar.gz → 0.2.60__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {exstruct-0.2.51 → exstruct-0.2.60}/PKG-INFO +46 -21
- {exstruct-0.2.51 → exstruct-0.2.60}/README.md +45 -20
- {exstruct-0.2.51 → exstruct-0.2.60}/pyproject.toml +2 -1
- {exstruct-0.2.51 → exstruct-0.2.60}/src/exstruct/__init__.py +49 -1
- {exstruct-0.2.51 → exstruct-0.2.60}/src/exstruct/core/integrate.py +376 -253
- {exstruct-0.2.51 → exstruct-0.2.60}/src/exstruct/engine.py +519 -455
- {exstruct-0.2.51 → exstruct-0.2.60}/src/exstruct/io/__init__.py +98 -12
- {exstruct-0.2.51 → exstruct-0.2.60}/src/exstruct/models/__init__.py +7 -6
- {exstruct-0.2.51 → exstruct-0.2.60}/LICENSE +0 -0
- {exstruct-0.2.51 → exstruct-0.2.60}/src/exstruct/cli/main.py +0 -0
- {exstruct-0.2.51 → exstruct-0.2.60}/src/exstruct/core/__init__.py +0 -0
- {exstruct-0.2.51 → exstruct-0.2.60}/src/exstruct/core/cells.py +0 -0
- {exstruct-0.2.51 → exstruct-0.2.60}/src/exstruct/core/charts.py +0 -0
- {exstruct-0.2.51 → exstruct-0.2.60}/src/exstruct/core/shapes.py +0 -0
- {exstruct-0.2.51 → exstruct-0.2.60}/src/exstruct/models/maps.py +0 -0
- {exstruct-0.2.51 → exstruct-0.2.60}/src/exstruct/models/types.py +0 -0
- {exstruct-0.2.51 → exstruct-0.2.60}/src/exstruct/py.typed +0 -0
- {exstruct-0.2.51 → exstruct-0.2.60}/src/exstruct/render/__init__.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: exstruct
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.60
|
|
4
4
|
Summary: Excel to structured JSON (tables, shapes, charts) for LLM/RAG pipelines
|
|
5
5
|
Keywords: excel,structure,data,exstruct
|
|
6
6
|
Author: harumiWeb
|
|
@@ -60,12 +60,15 @@ Description-Content-Type: text/markdown
|
|
|
60
60
|
|
|
61
61
|

|
|
62
62
|
|
|
63
|
-
ExStruct reads Excel workbooks and outputs structured data (cells, table candidates, shapes, charts, print areas/views, hyperlinks) as JSON by default, with optional YAML/TOON formats. It targets both COM/Excel environments (rich extraction) and non-COM environments (cells + table candidates + print areas), with tunable detection heuristics and multiple output modes to fit LLM/RAG pipelines.
|
|
63
|
+
ExStruct reads Excel workbooks and outputs structured data (cells, table candidates, shapes, charts, print areas/views, auto page-break areas, hyperlinks) as JSON by default, with optional YAML/TOON formats. It targets both COM/Excel environments (rich extraction) and non-COM environments (cells + table candidates + print areas), with tunable detection heuristics and multiple output modes to fit LLM/RAG pipelines.
|
|
64
|
+
|
|
65
|
+
[日本版README](README.ja.md)
|
|
64
66
|
|
|
65
67
|
## Features
|
|
66
68
|
|
|
67
|
-
- **Excel → Structured JSON**: cells, shapes, charts, table candidates,
|
|
69
|
+
- **Excel → Structured JSON**: cells, shapes, charts, table candidates, print areas/views, and auto page-break areas per sheet.
|
|
68
70
|
- **Output modes**: `light` (cells + table candidates + print areas; no COM, shapes/charts empty), `standard` (texted shapes + arrows, charts, print areas), `verbose` (all shapes with width/height, charts with size, print areas). Verbose also emits cell hyperlinks. Size output is flag-controlled.
|
|
71
|
+
- **Auto page-break export (COM only)**: capture Excel-computed auto page breaks and write per-area JSON/YAML/TOON when requested.
|
|
69
72
|
- **Formats**: JSON (compact by default, `--pretty` available), YAML, TOON (optional dependencies).
|
|
70
73
|
- **Table detection tuning**: adjust heuristics at runtime via API.
|
|
71
74
|
- **CLI rendering** (Excel required): optional PDF and per-sheet PNGs.
|
|
@@ -101,6 +104,8 @@ exstruct input.xlsx --mode light # cells + table candidates only
|
|
|
101
104
|
exstruct input.xlsx --pdf --image # PDF and PNGs (Excel required)
|
|
102
105
|
```
|
|
103
106
|
|
|
107
|
+
Auto page-break exports are API-only (Excel/COM): set `DestinationOptions.auto_page_breaks_dir` or call `export_auto_page_breaks(...)`.
|
|
108
|
+
|
|
104
109
|
## Quick Start (Python)
|
|
105
110
|
|
|
106
111
|
```python
|
|
@@ -122,27 +127,45 @@ wb.save("out.json", pretty=True) # WorkbookData → file (by extension)
|
|
|
122
127
|
first_sheet.save("sheet.json") # SheetData → file (by extension)
|
|
123
128
|
print(first_sheet.to_yaml()) # YAML text (requires pyyaml)
|
|
124
129
|
|
|
125
|
-
# ExStructEngine: per-instance options (nested configs)
|
|
126
|
-
from exstruct import
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
130
|
+
# ExStructEngine: per-instance options (nested configs)
|
|
131
|
+
from exstruct import (
|
|
132
|
+
DestinationOptions,
|
|
133
|
+
ExStructEngine,
|
|
134
|
+
FilterOptions,
|
|
135
|
+
FormatOptions,
|
|
136
|
+
OutputOptions,
|
|
137
|
+
StructOptions,
|
|
138
|
+
export_auto_page_breaks,
|
|
139
|
+
)
|
|
140
|
+
|
|
141
|
+
engine = ExStructEngine(
|
|
142
|
+
options=StructOptions(mode="verbose"), # verbose includes hyperlinks by default
|
|
143
|
+
output=OutputOptions(
|
|
144
|
+
format=FormatOptions(pretty=True),
|
|
145
|
+
filters=FilterOptions(include_shapes=False), # drop shapes in output
|
|
146
|
+
destinations=DestinationOptions(sheets_dir=Path("out_sheets")), # also write per-sheet files
|
|
147
|
+
),
|
|
148
|
+
)
|
|
149
|
+
wb2 = engine.extract("input.xlsx")
|
|
150
|
+
engine.export(wb2, Path("out_filtered.json")) # drops shapes via filters
|
|
151
|
+
|
|
152
|
+
# Enable hyperlinks in other modes
|
|
153
|
+
engine_links = ExStructEngine(options=StructOptions(mode="standard", include_cell_links=True))
|
|
154
|
+
with_links = engine_links.extract("input.xlsx")
|
|
142
155
|
|
|
143
156
|
# Export per print area (if print areas exist)
|
|
144
157
|
from exstruct import export_print_areas_as
|
|
145
158
|
export_print_areas_as(wb, "areas", fmt="json", pretty=True)
|
|
159
|
+
|
|
160
|
+
# Auto page-break extraction/output (COM only; raises if no auto breaks exist)
|
|
161
|
+
engine_auto = ExStructEngine(
|
|
162
|
+
output=OutputOptions(
|
|
163
|
+
destinations=DestinationOptions(auto_page_breaks_dir=Path("auto_areas"))
|
|
164
|
+
)
|
|
165
|
+
)
|
|
166
|
+
wb_auto = engine_auto.extract("input.xlsx") # includes SheetData.auto_print_areas
|
|
167
|
+
engine_auto.export(wb_auto, Path("out_with_auto.json")) # also writes auto_areas/*
|
|
168
|
+
export_auto_page_breaks(wb_auto, "auto_areas", fmt="json", pretty=True) # manual writer
|
|
146
169
|
```
|
|
147
170
|
|
|
148
171
|
**Note (non-COM environments):** If Excel COM is unavailable, extraction still runs and returns cells + `table_candidates`; `shapes`/`charts` will be empty.
|
|
@@ -382,10 +405,12 @@ In short, **exstruct = “an engine that converts Excel into a format AI can und
|
|
|
382
405
|
- Default JSON is compact to reduce tokens; use `--pretty` or `pretty=True` when readability matters.
|
|
383
406
|
- Field `table_candidates` replaces `tables`; adjust downstream consumers accordingly.
|
|
384
407
|
|
|
385
|
-
## Print Areas (PrintArea / PrintAreaView)
|
|
408
|
+
## Print Areas and Auto Page Breaks (PrintArea / PrintAreaView)
|
|
386
409
|
|
|
387
410
|
- `SheetData.print_areas` holds print areas (cell coordinates) in light/standard/verbose.
|
|
411
|
+
- `SheetData.auto_print_areas` holds Excel COM-computed auto page-break areas when auto page-break extraction is enabled (COM only).
|
|
388
412
|
- Use `export_print_areas_as(...)` or CLI `--print-areas-dir` to write one file per print area (nothing is written if none exist).
|
|
413
|
+
- Use `DestinationOptions.auto_page_breaks_dir` (preferred) or `export_auto_page_breaks(...)` to write per-auto-page-break files; the API raises `ValueError` if no auto page breaks exist.
|
|
389
414
|
- `PrintAreaView` includes rows and table candidates inside the area, plus shapes/charts that overlap the area (size-less shapes are treated as points). `normalize=True` rebases row/col indices to the area origin.
|
|
390
415
|
|
|
391
416
|
## License
|
|
@@ -4,12 +4,15 @@
|
|
|
4
4
|
|
|
5
5
|

|
|
6
6
|
|
|
7
|
-
ExStruct reads Excel workbooks and outputs structured data (cells, table candidates, shapes, charts, print areas/views, hyperlinks) as JSON by default, with optional YAML/TOON formats. It targets both COM/Excel environments (rich extraction) and non-COM environments (cells + table candidates + print areas), with tunable detection heuristics and multiple output modes to fit LLM/RAG pipelines.
|
|
7
|
+
ExStruct reads Excel workbooks and outputs structured data (cells, table candidates, shapes, charts, print areas/views, auto page-break areas, hyperlinks) as JSON by default, with optional YAML/TOON formats. It targets both COM/Excel environments (rich extraction) and non-COM environments (cells + table candidates + print areas), with tunable detection heuristics and multiple output modes to fit LLM/RAG pipelines.
|
|
8
|
+
|
|
9
|
+
[日本版README](README.ja.md)
|
|
8
10
|
|
|
9
11
|
## Features
|
|
10
12
|
|
|
11
|
-
- **Excel → Structured JSON**: cells, shapes, charts, table candidates,
|
|
13
|
+
- **Excel → Structured JSON**: cells, shapes, charts, table candidates, print areas/views, and auto page-break areas per sheet.
|
|
12
14
|
- **Output modes**: `light` (cells + table candidates + print areas; no COM, shapes/charts empty), `standard` (texted shapes + arrows, charts, print areas), `verbose` (all shapes with width/height, charts with size, print areas). Verbose also emits cell hyperlinks. Size output is flag-controlled.
|
|
15
|
+
- **Auto page-break export (COM only)**: capture Excel-computed auto page breaks and write per-area JSON/YAML/TOON when requested.
|
|
13
16
|
- **Formats**: JSON (compact by default, `--pretty` available), YAML, TOON (optional dependencies).
|
|
14
17
|
- **Table detection tuning**: adjust heuristics at runtime via API.
|
|
15
18
|
- **CLI rendering** (Excel required): optional PDF and per-sheet PNGs.
|
|
@@ -45,6 +48,8 @@ exstruct input.xlsx --mode light # cells + table candidates only
|
|
|
45
48
|
exstruct input.xlsx --pdf --image # PDF and PNGs (Excel required)
|
|
46
49
|
```
|
|
47
50
|
|
|
51
|
+
Auto page-break exports are API-only (Excel/COM): set `DestinationOptions.auto_page_breaks_dir` or call `export_auto_page_breaks(...)`.
|
|
52
|
+
|
|
48
53
|
## Quick Start (Python)
|
|
49
54
|
|
|
50
55
|
```python
|
|
@@ -66,27 +71,45 @@ wb.save("out.json", pretty=True) # WorkbookData → file (by extension)
|
|
|
66
71
|
first_sheet.save("sheet.json") # SheetData → file (by extension)
|
|
67
72
|
print(first_sheet.to_yaml()) # YAML text (requires pyyaml)
|
|
68
73
|
|
|
69
|
-
# ExStructEngine: per-instance options (nested configs)
|
|
70
|
-
from exstruct import
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
74
|
+
# ExStructEngine: per-instance options (nested configs)
|
|
75
|
+
from exstruct import (
|
|
76
|
+
DestinationOptions,
|
|
77
|
+
ExStructEngine,
|
|
78
|
+
FilterOptions,
|
|
79
|
+
FormatOptions,
|
|
80
|
+
OutputOptions,
|
|
81
|
+
StructOptions,
|
|
82
|
+
export_auto_page_breaks,
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
engine = ExStructEngine(
|
|
86
|
+
options=StructOptions(mode="verbose"), # verbose includes hyperlinks by default
|
|
87
|
+
output=OutputOptions(
|
|
88
|
+
format=FormatOptions(pretty=True),
|
|
89
|
+
filters=FilterOptions(include_shapes=False), # drop shapes in output
|
|
90
|
+
destinations=DestinationOptions(sheets_dir=Path("out_sheets")), # also write per-sheet files
|
|
91
|
+
),
|
|
92
|
+
)
|
|
93
|
+
wb2 = engine.extract("input.xlsx")
|
|
94
|
+
engine.export(wb2, Path("out_filtered.json")) # drops shapes via filters
|
|
95
|
+
|
|
96
|
+
# Enable hyperlinks in other modes
|
|
97
|
+
engine_links = ExStructEngine(options=StructOptions(mode="standard", include_cell_links=True))
|
|
98
|
+
with_links = engine_links.extract("input.xlsx")
|
|
86
99
|
|
|
87
100
|
# Export per print area (if print areas exist)
|
|
88
101
|
from exstruct import export_print_areas_as
|
|
89
102
|
export_print_areas_as(wb, "areas", fmt="json", pretty=True)
|
|
103
|
+
|
|
104
|
+
# Auto page-break extraction/output (COM only; raises if no auto breaks exist)
|
|
105
|
+
engine_auto = ExStructEngine(
|
|
106
|
+
output=OutputOptions(
|
|
107
|
+
destinations=DestinationOptions(auto_page_breaks_dir=Path("auto_areas"))
|
|
108
|
+
)
|
|
109
|
+
)
|
|
110
|
+
wb_auto = engine_auto.extract("input.xlsx") # includes SheetData.auto_print_areas
|
|
111
|
+
engine_auto.export(wb_auto, Path("out_with_auto.json")) # also writes auto_areas/*
|
|
112
|
+
export_auto_page_breaks(wb_auto, "auto_areas", fmt="json", pretty=True) # manual writer
|
|
90
113
|
```
|
|
91
114
|
|
|
92
115
|
**Note (non-COM environments):** If Excel COM is unavailable, extraction still runs and returns cells + `table_candidates`; `shapes`/`charts` will be empty.
|
|
@@ -326,10 +349,12 @@ In short, **exstruct = “an engine that converts Excel into a format AI can und
|
|
|
326
349
|
- Default JSON is compact to reduce tokens; use `--pretty` or `pretty=True` when readability matters.
|
|
327
350
|
- Field `table_candidates` replaces `tables`; adjust downstream consumers accordingly.
|
|
328
351
|
|
|
329
|
-
## Print Areas (PrintArea / PrintAreaView)
|
|
352
|
+
## Print Areas and Auto Page Breaks (PrintArea / PrintAreaView)
|
|
330
353
|
|
|
331
354
|
- `SheetData.print_areas` holds print areas (cell coordinates) in light/standard/verbose.
|
|
355
|
+
- `SheetData.auto_print_areas` holds Excel COM-computed auto page-break areas when auto page-break extraction is enabled (COM only).
|
|
332
356
|
- Use `export_print_areas_as(...)` or CLI `--print-areas-dir` to write one file per print area (nothing is written if none exist).
|
|
357
|
+
- Use `DestinationOptions.auto_page_breaks_dir` (preferred) or `export_auto_page_breaks(...)` to write per-auto-page-break files; the API raises `ValueError` if no auto page breaks exist.
|
|
333
358
|
- `PrintAreaView` includes rows and table candidates inside the area, plus shapes/charts that overlap the area (size-less shapes are treated as points). `normalize=True` rebases row/col indices to the area origin.
|
|
334
359
|
|
|
335
360
|
## License
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "exstruct"
|
|
3
|
-
version = "0.2.
|
|
3
|
+
version = "0.2.60"
|
|
4
4
|
description = "Excel to structured JSON (tables, shapes, charts) for LLM/RAG pipelines"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
license = { file = "LICENSE" }
|
|
@@ -26,6 +26,7 @@ build-backend = "uv_build"
|
|
|
26
26
|
dev = [
|
|
27
27
|
"mkdocs-material>=9.7.0",
|
|
28
28
|
"mypy>=1.19.0",
|
|
29
|
+
"pre-commit>=4.5.0",
|
|
29
30
|
"pytest>=9.0.1",
|
|
30
31
|
"pytest-cov>=7.0.0",
|
|
31
32
|
"pytest-mock>=3.15.1",
|
|
@@ -5,11 +5,18 @@ from typing import Literal, TextIO
|
|
|
5
5
|
|
|
6
6
|
from .core.cells import set_table_detection_params
|
|
7
7
|
from .core.integrate import extract_workbook
|
|
8
|
-
from .engine import
|
|
8
|
+
from .engine import (
|
|
9
|
+
DestinationOptions,
|
|
10
|
+
ExStructEngine,
|
|
11
|
+
FilterOptions,
|
|
12
|
+
OutputOptions,
|
|
13
|
+
StructOptions,
|
|
14
|
+
)
|
|
9
15
|
from .io import (
|
|
10
16
|
save_as_json,
|
|
11
17
|
save_as_toon,
|
|
12
18
|
save_as_yaml,
|
|
19
|
+
save_auto_page_break_views,
|
|
13
20
|
save_print_area_views,
|
|
14
21
|
save_sheets,
|
|
15
22
|
serialize_workbook,
|
|
@@ -32,6 +39,7 @@ __all__ = [
|
|
|
32
39
|
"export_sheets",
|
|
33
40
|
"export_sheets_as",
|
|
34
41
|
"export_print_areas_as",
|
|
42
|
+
"export_auto_page_breaks",
|
|
35
43
|
"export_pdf",
|
|
36
44
|
"export_sheet_images",
|
|
37
45
|
"process_excel",
|
|
@@ -49,7 +57,10 @@ __all__ = [
|
|
|
49
57
|
"ExStructEngine",
|
|
50
58
|
"StructOptions",
|
|
51
59
|
"OutputOptions",
|
|
60
|
+
"FilterOptions",
|
|
61
|
+
"DestinationOptions",
|
|
52
62
|
"serialize_workbook",
|
|
63
|
+
"export_auto_page_breaks",
|
|
53
64
|
]
|
|
54
65
|
|
|
55
66
|
|
|
@@ -158,6 +169,39 @@ def export_print_areas_as(
|
|
|
158
169
|
)
|
|
159
170
|
|
|
160
171
|
|
|
172
|
+
def export_auto_page_breaks(
|
|
173
|
+
data: WorkbookData,
|
|
174
|
+
dir_path: str | Path,
|
|
175
|
+
fmt: Literal["json", "yaml", "yml", "toon"] = "json",
|
|
176
|
+
*,
|
|
177
|
+
pretty: bool = False,
|
|
178
|
+
indent: int | None = None,
|
|
179
|
+
normalize: bool = False,
|
|
180
|
+
) -> dict[str, Path]:
|
|
181
|
+
"""
|
|
182
|
+
Export auto page-break areas (COM-computed) as PrintAreaView files.
|
|
183
|
+
|
|
184
|
+
Args:
|
|
185
|
+
data: WorkbookData containing auto_print_areas (COM extraction with auto breaks enabled)
|
|
186
|
+
dir_path: output directory
|
|
187
|
+
fmt: json/yaml/yml/toon
|
|
188
|
+
pretty/indent: JSON formatting options
|
|
189
|
+
normalize: rebase row/col indices to the area origin when True
|
|
190
|
+
"""
|
|
191
|
+
if not any(sheet.auto_print_areas for sheet in data.sheets.values()):
|
|
192
|
+
raise ValueError(
|
|
193
|
+
"No auto page-break areas found. Enable COM-based auto page breaks before exporting."
|
|
194
|
+
)
|
|
195
|
+
return save_auto_page_break_views(
|
|
196
|
+
data,
|
|
197
|
+
Path(dir_path),
|
|
198
|
+
fmt=fmt,
|
|
199
|
+
pretty=pretty,
|
|
200
|
+
indent=indent,
|
|
201
|
+
normalize=normalize,
|
|
202
|
+
)
|
|
203
|
+
|
|
204
|
+
|
|
161
205
|
def process_excel(
|
|
162
206
|
file_path: Path,
|
|
163
207
|
output_path: Path | None = None,
|
|
@@ -170,6 +214,7 @@ def process_excel(
|
|
|
170
214
|
indent: int | None = None,
|
|
171
215
|
sheets_dir: Path | None = None,
|
|
172
216
|
print_areas_dir: Path | None = None,
|
|
217
|
+
auto_page_breaks_dir: Path | None = None,
|
|
173
218
|
stream: TextIO | None = None,
|
|
174
219
|
) -> None:
|
|
175
220
|
"""
|
|
@@ -185,6 +230,7 @@ def process_excel(
|
|
|
185
230
|
pretty/indent: JSON formatting
|
|
186
231
|
sheets_dir: directory to write per-sheet files
|
|
187
232
|
print_areas_dir: directory to write per-print-area files
|
|
233
|
+
auto_page_breaks_dir: directory to write per-auto-page-break files (COM only)
|
|
188
234
|
stream: IO override when output_path is None
|
|
189
235
|
"""
|
|
190
236
|
engine = ExStructEngine(
|
|
@@ -195,6 +241,7 @@ def process_excel(
|
|
|
195
241
|
indent=indent,
|
|
196
242
|
sheets_dir=sheets_dir,
|
|
197
243
|
print_areas_dir=print_areas_dir,
|
|
244
|
+
auto_page_breaks_dir=auto_page_breaks_dir,
|
|
198
245
|
include_print_areas=None if mode == "light" else True,
|
|
199
246
|
include_shape_size=True if mode == "verbose" else False,
|
|
200
247
|
include_chart_size=True if mode == "verbose" else False,
|
|
@@ -213,5 +260,6 @@ def process_excel(
|
|
|
213
260
|
indent=indent,
|
|
214
261
|
sheets_dir=sheets_dir,
|
|
215
262
|
print_areas_dir=print_areas_dir,
|
|
263
|
+
auto_page_breaks_dir=auto_page_breaks_dir,
|
|
216
264
|
stream=stream,
|
|
217
265
|
)
|