Excel To Code
Converts some excel spreadsheets (.xlsx, not .xls) into C. This allows the excel spreadsheets to be run programatically, without excel, anywhere that compiles basic dependency free C code. This can be handy to allow excel to be used as the calculating engine behind websites (e.g., The DECC 2050 Pathways Calculator is powered by this 50+ page excel model).
Prepare
Make sure you have ruby 1.9.2 or later installed, a copy of git, and a basic C compiler
Install
gem install bundler # May need to use sudo
git clone https://github.com/tamc/excel_to_code.git
cd excel_to_code
bundle
Run
Can be run as a command line:
./bin/excel_to_c <excel_file_name>
… with several options:
./bin/excel_to_c --compile --run-tests --settable <name of input worksheet> --prune-except <name of output worksheet> <excel file name>
… or as a ruby library, see the examples directory for ideas.
Know the limits
- Not tested at all on Windows
- INDIRECT and OFFSET formula must be convertable at runtime into a standard formula
- Doesn't implement all functions (just the handful of functions with an R or C after their name in this list )
- Implements the usual cell and range references but doesn't implement references that involve range unions and lists or references to external worksheets
- Sometimes gives cells as being empty, when excel would give the cell as having a numeric value of zero