Excel Art – The New ASCII Art?

Reading my daily CodeProject newsletter today, I came across this article about a Japanese artist who uses the graphic editing tools in Excel to create art.

Like many commenters, I disappointed that he hadn’t actually used Excel cells to create the image in the style of Pointillism.

If you know C# this is not a problem, and a few minutes later we have this code:

            // gembox spreadsheet key set
            GemBox.Spreadsheet.SpreadsheetInfo.SetLicense("[redacted]");

            // create the Excel output file
            var xl = new GemBox.Spreadsheet.ExcelFile();
            var ws = xl.Worksheets.Add("IBMPC");

            const string imageResource= "ExcelPaint.IBM PC 5150.jpg";

            var thisEXE = System.Reflection.Assembly.GetExecutingAssembly();
            using (var resource = thisEXE.GetManifestResourceStream(imageResource)) 
            {
                var img = new Bitmap(resource);
                for (int x = 0; x < img.Width; x++)
                {
                    for (int y = 0; y < img.Height; y++)
                    {
                        // get pixel colour from image
                        Color pixel = img.GetPixel(x, y);

                        // write to Excel cell
                        ws.Cells[y, x].Style.FillPattern.PatternForegroundColor= pixel;
                        ws.Cells[y, x].Style.FillPattern.PatternStyle = GemBox.Spreadsheet.FillPatternStyle.Solid;
                    }
                }
            }

            xl.SaveXlsx("C:\\IBMPC5050.xlsx");

I use the excellent GemBox SpreadSheet library for my Excel interaction. The code should not really need any explanation: read a pixel, write a “pixel”.

The resulting output is an Excel Spreadsheet, as shown below. Initially the aspect-ratio of the image was distorted as the cells were not square. I manually resized the column widths to 2, and it looks correct.

image

You can download the resulting output yourself here. I have to admit this is not going to win awards for image compression techniques: the original JPG was only 43KB and the Excel sheet was 1291KB. But hey, it’s 100% cooler.

For reference this is the original image:

In case you’re wondering – why an old PC as a test picture? This was the first suitable image I found, it’s one of my collection of old computers. It’s also a reference to the ASCII art of days gone by.