📊 A Python module for handling embedded images in spreadsheets.
Currently supports Excel (OpenPyXL), with Google Sheets support coming soon.
pip install git+https://github.com/sbcodeworks/sheet-image-handler.gitgit clone https://github.com/sbcodeworks/sheet-image-handler.git
cd sheet-image-handler
pip install .from openpyxl import Workbook
from PIL import Image
from sheet_image_handler import SheetImageHandler
# Create a new Excel workbook & sheet
wb = Workbook()
ws = wb.active
# Initialize the handler
handler = SheetImageHandler(ws)
# Load an image and write it to a cell
img = Image.open("example.png")
handler.write("A1", img)
# Save the workbook
wb.save("output.xlsx")
# Check if an image is in a cell
print(handler.image_in("A1")) # True
# Retrieve and show an image from a cell
retrieved_img = handler.get("A1")
retrieved_img.show()
# Remove an image
handler.remove("A1")✅ Load existing images from an Excel sheet
✅ Add new images to a specified cell
✅ Retrieve images from a cell as a PIL Image
✅ Remove images from a sheet
- Google Sheets support (using
gspread) - More advanced image manipulation (resize, scaling, auto-alignment)
- Multi-format support
To run the test suite, ensure you have pytest installed:
pip install pytestThen, navigate to the project root and run:
pytest tests/For detailed output, use:
pytest -v tests/To run a specific test:
pytest tests/test_sheet_image_handler.py::test_function_nameTo check test coverage (requires pytest-cov):
pip install pytest-cov
pytest --cov=sheet_image_handler tests/Happy testing! 🚀
This project is licensed under the MIT License.
Pull requests are welcome! To contribute:
- Fork the repo
- Create a new branch (
git checkout -b feature-new) - Commit changes (
git commit -m "Add new feature") - Push to the branch (
git push origin feature-new) - Open a Pull Request
Happy coding! 🚀