Click here to Skip to main content
14,022,154 members
Click here to Skip to main content
Add your own
alternative version


4 bookmarked
Posted 30 Aug 2017
Licenced CPOL

Excel Pixelating Image Creator

, 30 Aug 2017
Rate this:
Please Sign up or sign in to vote.
Use Excel worksheet's cells as pixels to render real image (for fun and experiment)


This little project is to use Excel worksheet's cells as pixels to render real image. It needs .NET 4.5 and local Excel to run. It's coded in C#/winform/VS 2013.


Basically, the winform app picks an image from your hard drive, and launches Excel to render the picked image with worksheet cells.

The brief running process is as below:

(1) It picks the image and resample it into the memory according to your UI inputs (units, columns etc.)

(2) It launches Excel, make the spreadsheet cell square-like to simulate a big pixel

(3) It scans the resampled image in memory either in a linear way or random way (I prefer random way, the effect is so fun to watch).

(4) It changes cell's background color, one by one (in either linear order or random order)

(This is what the app looks like)


(It's rendering in Excel in a random way)


(Rendering is done)

Using the code

The code is very strait forward. It uses VS 2013 (or above), .NET 4.5, C# and winform.

Make sure you have Office Interop Excel refered properly


Points of Interest

(1) Running progress popup

Originally I thought I need to do async/await to make a decent progress popup. But you know what, after so many years, this so called "long-run" process handling framework still hard to use unless you do it on daily basis. plus, you have to deal with COM+/Office Interop with this new async/await thing. Done some experiments, I decide to go with another approach. 

It turns out that, just a regular call can handle it decently. Maybe it's because Office Interop, the system already takes care of this kind of async, worker thread, UI thread swiching myth. Frankly, I don't know. But it works.

You can see the yellow marked code, no fancy async/await stuff, but still does the trick smoothly. 

Obviously the above method still missing a feature: "Cancel".

To cancel a long run process in middle, folks, it's not an easy thing to do. It's advanced topic and case by case (sometimes you want to rollback, sometimes you just want to kill it...).  I'm busy on living my own life and this "feature" actually disturbs the main purpose of this little project, so I...


(2) performance

If you mess this little app with big size image or super small cells (by change the cell unit size), it will be super slow. keep in mind that Excel worksheet has limitations (1048576 rows X 16384 cols). But before you even try those numbers, I warned you in my code comments:

(3) performance again

In my experiment, while image rendering, if the "focus" is on Excel, it's slow. But if "focus" is out of Excel, it's faster. Don't ask me why. If you want to figure it out, go nuts, it's all yours. But my humble approach is just to make sure the app is having the focus.

Can you believe it? This is 2017 and .NET 5.0 era (am I right?) and when you want to do some basic things like "switching focus", you still have to rely on almighty WIN32!

(4) Randomization

I put the default rendering effect is "Randomization". It's fun to watch. It's well documented in my comments. Just a reminder here as well: it's not "real" random method. It's just good enough to cheat on human eyes.

(5) The test image

I put a photo of "this guy"' as test image for your convenience. It's packaged in the source code zip. 


That's about it. Just download the source and play around. I think my comments are also good for you to understand the code. 

The souce code solution project is here:



I also made a YouTube video to show how it runs. Have fun:




This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Software Developer
Canada Canada
Just A Geek

You may also be interested in...

Comments and Discussions

GeneralNice project Pin
Mario Z10-Sep-17 1:49
professionalMario Z10-Sep-17 1:49 
GeneralRe: Nice project Pin
Geek2Simon11-Sep-17 12:45
memberGeek2Simon11-Sep-17 12:45 
QuestionDitto Pin
Doncp31-Aug-17 10:29
memberDoncp31-Aug-17 10:29 
AnswerRe: Ditto Pin
Geek2Simon31-Aug-17 13:07
memberGeek2Simon31-Aug-17 13:07 
PraiseMy vote of 5 Pin
Doom For Ever31-Aug-17 8:41
professionalDoom For Ever31-Aug-17 8:41 
GeneralRe: My vote of 5 Pin
Geek2Simon31-Aug-17 13:07
memberGeek2Simon31-Aug-17 13:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web03 | 2.8.190417.4 | Last Updated 30 Aug 2017
Article Copyright 2017 by Geek2Simon
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid