Spreadsheets are usually the wrong solution for anything where you care about correctness.
Unless I've missed something, and there are unit and integration testing frameworks for spreadsheets?
@liw spreadsheets with types are a partial solution.
There's an excel addon, but I don't think libreoffice has one.
Lars and friends