Calc C# SDK: sample program to read/write images in cells (ADDPIX)

I’ve spent the past few months trying to get a C# program written which uses the SDK to read cells from a Calc spreadsheet and read/write/modify images “in” cells. I got a lot of help in these forums for which I’m very grateful. At first I was told that it wasn’t possible, but that just made me determined to figure out how to do it, and I finally did. It took many times the amount of time that the program will end up saving me, but hopefully it will be helpful to others trying to do similar things.

The original task arose as a result of my mother passing away and leaving me and my siblings with a large condo full of things that needed to be disposed of. We sorted out the things of sentimental or monetary value, assigned item numbers to them, and put them in a spreadsheet to facilitate distribution to us siblings as well as disposal of things that none of us wants. The spreadsheet includes pictures of the items, and adding and maintaining those pictures ended up being a lot of work.

The program ADDPIX works with the spreadsheet format that we used for the task of maintaining those pictures. It can add new pictures, delete pictures, refresh pictures with new copies, and adjust the size and position of images so they fit and are centered in their cells. As is, it is very specific to this application and spreadsheet format. It would only be useful as is to someone facing a similar task of inventorying, documenting, and disposing a large number of items. However, it would be very useful as a source of code samples to someone writing a program to work with Calc spreadsheets using the LibreOffice SDK.

The various tasks that ADDPIX does to manipulate the spreadsheet are delineated in the code with comments to make them easy to find and copy into your code. The C# code itself is linear and simple so it is easy to understand and so the parts that do various things are pretty much independent.

Included in the ADDPIX package is the source and executable, a sample spreadsheet with associated sample images, and a text file with a detailed description of the program, what it does, how to use it, how it works, and how to use it in your own code.

I will soon be posting two more detailed articles on ADDPIX on my EXEYE website. The first article describes the task ADDPIX was written for, and is intended for people who need a program to catalog large numbers of items with pictures, especially those who are trying to dispose of items from an estate.

It seems that I can’t upload a zip file into this forum. You can download it from addpix.zip. Unzip it into “C:\ods-addpix” so everything will work as is.

I hope this proves useful to others.

-jimc

An update to the above post, since I can’t further edit it:

The paragraph that mentions two articles on my website is incorrect and should be revised to the following:

I will soon be posting two more detailed articles on ADDPIX on my EXEYE website. The first article describes the program ADDPIX, what it does and how it works, and how it could be useful to programmers trying to write a C# SDK program to work with LibreOffice Calc spreadsheets, especially for those wishing to add/remove/modify images “in” spreadsheet cells.

BTW, I need a “like” (among other things) to advance to the user level where I can make multiple edits to my posts. If you find this post of value to you, please “like” it. Thank you.

-jimc