A few months ago I needed to convert quite complex (kind of black box) computation from Excel spreadsheet to C code. At first I manually copied expressions from all cells but this was not simple as I had to check cells mentioned in expressions (formulas). It took long time and energy and the code didn’t work properly - results calculated by the spreadsheet differed from my program’s result.
Therefore I decided to save the Excel spreadsheet in ODF format (OpenOffice.org Calc) and write a little helper called SpreadsheetToCode. It’s a command-line utility that does the following steps:
- Load OpenDocument Spreadsheet file (.ods) because it's basically XML file wrapped in ZIP and therefore super easy to handle
- Pick all cells which contain numerical values (inputs, parameters) or expressions with them (formulas)
- Print C-like source code with the spreadsheet's functionality expressed in lines of code