Excel, long known for its love affair with numbers, has now developed a taste for images—thanks to Python. Microsoft has rolled out a feature that lets users insert images into individual Excel cells and analyze them using Python code. Yes, the spreadsheet just got a little more artsy and a lot more tech-savvy.
Forget floating images hovering over cells like ghosts of clipart past. This update allows users to plop an image squarely into a single cell (no cell-merging acrobatics allowed). Once inside, the image can be called upon with the Python in Excel integration and subjected to various analytical or creative transformations.
How It Works (Spoiler: It’s Simpler Than Expected)
For this you’ll need Excel 365 with a business plan that supports the Python extension of Excel.
- Insert an image using the new
=IMAGE()function. Just keep it inside one cell, Excel likes its boundaries respected. - Open a Python cell using
=PY(and reference the image’s cell withxl("A1")(or wherever the image lives). - Use Python (and its faithful sidekick, Pillow) to do something clever. Microsoft’s demo? A sharpness detector using grayscale, Laplacian filters, and variance. High variance = “Sharp.” Low variance = “Blurry.”
- Hit Ctrl + Enter and—presto—the result appears like magic (or like solid coding).
The Python code
This is the sample code from Microsoft. It converts the image to grayscale, adds a Laplacian filter the classifies the image variance.
from PIL import Image
import numpy as np
from scipy.signal import convolve2d
# Convert image to grayscale and array
image = xl("A1")
arr = np.array(image.convert("L"), dtype=np.float32)
# Apply Laplacian filter
laplacian = convolve2d(arr, [[0, 1, 0], [1, -4, 1], [0, 1, 0]], mode='same', boundary='symm')
# Classify based on variance
"Blurry" if np.var(laplacian) < 100 else "Sharp"
What Can One Do with This Sorcery?
Besides checking if a selfie is blurry or not, users can:
- Adjust brightness and contrast.
- Add filters (hello, ExcelGram).
- Watermark documents without third-party tools.
- Extract metadata like image dimensions, camera info, or creation date.
- Create fun Python scripts to map pixel color distributions or even detect objects.
A Few Nerdy Details
- Pillow library (PIL) does the heavy lifting—opening, analyzing, and filtering image data right inside Excel.
- Users can control image resolution for performance purposes via File | Options | Advanced | Python in Excel. Options range from “Actual size” to “Small” (for the minimalist analyst).
- If Excel can’t handle the image size? It politely throws an error instead of crashing the party.
Who Gets to Play?
This feature is available to Microsoft 365 Insiders using:
- Windows: Excel 365 v2509 Build 19204.20002+
- Mac: Excel 365 v16.101 Build 25080524+
- Web: Microsoft promises it’ll rollout soon.