by tamc

Roughly translate some Excel spreadsheets to Ruby or C.

212 Stars 23 Forks Last release: over 2 years ago (0.3.17) MIT License 1.2K Commits 1 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:

Excel to Code

Tests Passing

exceltoc - roughly translate some Excel files into C.

exceltoruby - roughly translate some Excel files into Ruby.

This allows spreadsheets to be:

  1. Embedded in other programs, such as web servers, or optimisers
  2. Without depending on any Microsoft code

For example, running these commands turns this spreadsheet into this Ruby code or this C code.


Requires Ruby. Install by:

gem install excel_to_code


To just have a go:


This will produce a file called excelspreadsheet.c

For a more complex spreadsheet:

excel_to_c --compile --run-tests --settable  --prune-except   

See the full list of options:

excel_to_c --help

Gotchas, limitations and bugs

  1. No custom functions, no macros for generating results
  2. Results are cached. So you must call reset(), then set values, then read values.
  3. It must be possible to replace INDIRECT and OFFSET formula with standard references at compile time (e.g., INDIRECT("A"&"1") is fine, INDIRECT(userInput&"3") is not.
  4. Doesn't implement all functions. See which functions are implemented.
  5. Doesn't implement references that involve range unions and lists (but does implement standard ranges)
  6. Sometimes gives cells as being empty, when excel would give the cell as having a numeric value of zero
  7. The generated C version does not multithread and will give bad results if you try.
  8. The generated code uses floating point, rather than fully precise arithmetic, so results can differ slightly.
  9. The generated code uses the sprintf approach to rounding (even-odd) rather than excel's 0.5 rounds away from zero.
  10. Ranges like this: Sheet1!A10:Sheet1!B20 and 3D ranges don't work.

Report bugs: https://github.com/tamc/excel_to_code/issues


See Changes.


See License


Source code: https://github.com/tamc/excel_to_code


Some notes on how Excel works under the hood:

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.