Excel to Code¶
This guide walks you through the complete process of converting an Excel spreadsheet into a generated software project using the Codcel Desktop application.
Overview¶
The process follows five steps:
- Prepare your Excel file
- Import it into the Codcel Desktop app
- Configure settings for your project
- Generate the code
- Use the generated project
Step 1: Prepare Your Excel File¶
Before importing, ensure your Excel file follows the Excel Guidelines. Key points:
- Remove external links, comments, and embedded objects
- Delete unnecessary hidden sheets
- Ensure sheet names are unique and contain no special characters
- Save as
.xlsxfor best compatibility - Annotate your inputs and outputs using Codcel annotation syntax
Codcel reads your spreadsheet's formulas, cell references, and named ranges to understand the calculation logic. The cleaner your file, the better the generated code.
Step 2: Import into the Desktop App¶
- Open the Codcel Desktop application
- Create a new project or open an existing one (see Desktop Application Guide)
- In the sidebar, select Business Specs
- Drag and drop your Excel file into the import area, or click Browse to select it
- Wait for the import to complete -- a progress indicator shows the status
Your file is copied into the project's business_specs/ directory and registered in the project configuration. The original file is not modified.
Step 3: Configure Settings¶
Before generating code, review and adjust your project settings:
- Open Settings from the sidebar
- Set the Decimal Separator and Thousands Separator to match your Excel file's locale
- Set the Currency Symbol if your spreadsheet uses currency formatting
- Enable or disable Strict Type Conversion depending on how your spreadsheet handles mixed types
- If your spreadsheet contains circular references, enable Iterative Calculation and set appropriate iteration limits
- Click Save
For a complete list of settings and their effects, see the Settings Reference.
Step 4: Generate Code¶
- Open Generate Project from the sidebar
- Select the output targets you want:
- The Rust Calculation Library is always selected -- it is the core of every generated project
- Select additional targets such as REST API servers, web clients, or calculation libraries in other languages
- Some targets require a Codcel account (see Authentication)
- Click Generate
- A progress bar tracks the generation process
- When complete, the generated code appears in your project directory
Step 5: Use the Generated Project¶
After generation, your project directory contains the generated source code:
my-project/
├── codcel.toml # Project configuration
├── business_specs/ # Your imported Excel files
│ └── spreadsheet.xlsx
├── src/ # Generated Rust source code
│ ├── calculations.rs # Transpiled formulas
│ ├── model.rs # Data model definitions
│ └── constants.rs # Extracted constants and arrays
└── generated/ # Additional output targets
├── java-calculation/
├── restful-server/
├── web-client/
└── ...
Viewing Source Code in the App¶
After generation, new entries appear in the sidebar for each enabled output type. Click on any entry to view the generated source code directly within the application.
Building and Running¶
Each generated project includes the necessary build files for its language and framework:
- Rust projects include
Cargo.toml-- build withcargo build - Java/Kotlin projects include Gradle or Maven configuration
- Python projects include
setup.pyorpyproject.toml - C#/Go/Swift projects include their respective build configurations
For detailed build and run instructions for each output target, see Output Targets.
Testing¶
Each generated project includes test cases that verify the calculations match your Excel workbook. Run the tests using the standard test command for your target language (e.g., cargo test for Rust, ./gradlew test for Java).
For details on interpreting test results and adding custom tests, see Testing and Validation.
Regenerating¶
When your Excel file changes:
- Re-import the updated file in the Business Specs view
- Open Generate Project and click Generate again
- The generated code is updated to reflect the new spreadsheet logic
All settings and output target selections are preserved between generations.
What Gets Generated¶
Codcel reads your Excel file and generates:
- Calculation functions -- each output cell or named output becomes a function in the generated code
- Input parameters -- annotated input cells become function parameters
- Constants and arrays -- static data from the spreadsheet is extracted into constants
- Type-safe models -- data structures that represent your inputs and outputs
- Test documentation -- verification that generated calculations match your Excel results
- API endpoints -- if a server target is selected, each calculation becomes a REST endpoint
- Client libraries -- if a web client target is selected, typed client code is generated for calling the API
The generated code is fully human-readable, thoroughly commented, and yours to own. It has no runtime dependency on Codcel.
Next Steps¶
- Desktop Application Guide -- detailed guide to all features of the desktop app
- Settings Reference -- full reference for all configuration options
- UI Configuration -- configure generated UIs from within Excel
- Tables -- working with structured data tables
- Annotations -- complete guide to input, output, and table annotation syntax
- Differences Between Codcel and Excel -- understand where behaviour may differ