Embed WPS in-cell images into XLSX by editing OOXML parts
Project description
ce_img_ll
中文说明
ce_img_ll 用于通过修改 XLSX 底层 OOXML 部件,把图片以 WPS 单元格内图片(DISPIMG + cellimages.xml)的方式写入指定单元格。
功能特性
- 支持单张图片写入单个单元格。
- 支持批量图片写入多个单元格。
- 保留工作簿结构,输出采用原子写入,降低损坏风险。
- 同时提供 Python API 和命令行工具。
兼容性说明
- 本库实现的是 WPS 专有的单元格图片机制。
- 在 Microsoft Excel 中,可能显示为公式文本,或表现为部分兼容。
安装
pip install ce_img_ll
Python 用法
from pathlib import Path
from wpscellimg import embed_image, embed_images
embed_image(
source_xlsx=Path("input.xlsx"),
output_xlsx=Path("output.xlsx"),
sheet_name="Sheet1",
cell_ref="B2",
image_file=Path("photo.png"),
)
embed_images(
source_xlsx=Path("input.xlsx"),
output_xlsx=Path("output-batch.xlsx"),
sheet_name="Sheet1",
cell_image_map={
"A1": Path("a.png"),
"C3": Path("b.jpg"),
},
)
CLI 用法
ce-img-ll --source-xlsx input.xlsx --output-xlsx out.xlsx --sheet Sheet1 --cell A1 --image a.png
批量模式:
ce-img-ll --source-xlsx input.xlsx --output-xlsx out.xlsx --sheet Sheet1 --pair A1=a.png --pair B2=b.png
English Documentation
ce_img_ll embeds images into .xlsx cells using WPS-specific in-cell image mechanics by editing OOXML parts directly (DISPIMG + cellimages.xml).
Features
- Insert one image into one target cell.
- Batch insert multiple images into multiple cells.
- Preserve workbook structure and write output atomically.
- Provide both Python API and CLI.
Compatibility
- This library implements WPS-specific in-cell image behavior.
- In Microsoft Excel, cells may show formula text or have partial compatibility.
Installation
pip install ce_img_ll
Python Usage
from pathlib import Path
from wpscellimg import embed_image, embed_images
embed_image(
source_xlsx=Path("input.xlsx"),
output_xlsx=Path("output.xlsx"),
sheet_name="Sheet1",
cell_ref="B2",
image_file=Path("photo.png"),
)
embed_images(
source_xlsx=Path("input.xlsx"),
output_xlsx=Path("output-batch.xlsx"),
sheet_name="Sheet1",
cell_image_map={
"A1": Path("a.png"),
"C3": Path("b.jpg"),
},
)
CLI Usage
ce-img-ll --source-xlsx input.xlsx --output-xlsx out.xlsx --sheet Sheet1 --cell A1 --image a.png
Batch mode:
ce-img-ll --source-xlsx input.xlsx --output-xlsx out.xlsx --sheet Sheet1 --pair A1=a.png --pair B2=b.png
Development
python -m venv .venv
.venv\\Scripts\\python -m pip install -e . pytest
.venv\\Scripts\\python -m pytest
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ce_img_ll-0.1.0.tar.gz
(10.0 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
ce_img_ll-0.1.0-py3-none-any.whl
(11.2 kB
view details)
File details
Details for the file ce_img_ll-0.1.0.tar.gz.
File metadata
- Download URL: ce_img_ll-0.1.0.tar.gz
- Upload date:
- Size: 10.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ef17af99ce9ee8af1d267a2fdf8ca49e4e23324125414839d63db0f2ac597f5b
|
|
| MD5 |
074fc464520bb1ce252ee06318a708ca
|
|
| BLAKE2b-256 |
86800ff035715879f6a5ae228abb30db0188743ed50a3ae8cf8b8f461f76085f
|
File details
Details for the file ce_img_ll-0.1.0-py3-none-any.whl.
File metadata
- Download URL: ce_img_ll-0.1.0-py3-none-any.whl
- Upload date:
- Size: 11.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f15b3e8f6466430432bcbb91d76b14a050dd3d1a8b66446309474ca8c0d97b43
|
|
| MD5 |
c62c6d2dd9a5fdbd49e8d91cb82d22bf
|
|
| BLAKE2b-256 |
00d9d9d38534b5eebc4c69cac6b565679708e94af39da3dd86c8cf6597353a8d
|