Skip to main content

CalcBuilder Tutorial

Example: a simple tip / bill-splitting calculator (Excel spreadsheet)

▶ A 90-second video walkthrough of this example (English audio & subtitles). The written steps below cover the same ground.

This is the spreadsheet version of the tip calculator. Same three inputs, same result — tip, total and amount per person — but there is no PHP code. A small Excel workbook holds the three formulas, and Calc Builder runs it.

⇩ Download the sample workbook — tip_model.xlsx (5 KB)

Download the file above, open it to see how it is built, then upload your own copy in step 3.

1. The workbook (3 formulas)

One sheet named Tip. Three input cells, three formula cells:

  • B1 bill amount, B2 tip %, B3 number of people — the inputs.
  • B5 tip amount: =B1*B2/100
  • B6 total to pay: =B1+B5
  • B7 per person: =IF(B3>0, B6/B3, B6)

Give B5, B6 and B7 the number format 0.00 so they come back already rounded to two decimals.

2. Create the calculator and the form fields

Components → Calc Builder → Add → name it Tip Calculator (Excel). On Form Fields add three Number fields, exactly like the PHP version:

  • bill — “Bill amount (€)”, 2 decimals, default 100
  • tip_percent — “Tip %”, 2 decimals, default 15
  • people — “Number of people”, 0 decimals, default 2

The three number fields

3. Upload the workbook — Spreadsheet screen

Spreadsheet screen, Main tab

  1. Open the Spreadsheet screen from the toolbar.
  2. Choose File and pick tip_model.xlsx.
  3. Spreadsheet calculation launches: choose Before the code. The workbook runs first and its results become variables; since there is nothing else to do, the PHP box stays empty.
  4. Set Locale to English and leave the cache off.

4. Map the form fields to the input cells

Input fields mapping

On Input fields mapping, click Add once per field:

  • bill → sheet 0B1
  • tip_percent → sheet 0B2
  • people → sheet 0B3

5. Map the result cells to variables

Output fields mapping

On Output fields mapping:

  • 0 / B5tip_amount
  • 0 / B6total
  • 0 / B7per_person

Save. After the calculation, tip_amount, total and per_person exist as variables — just as if PHP had produced them.

6. PHP code — leave it empty

The PHP Code screen: nothing to write

Nothing to write here. The workbook already did everything. (A one-line comment is fine as a reminder.)

7. Exit Layout

Exit Layout

The result template is the same as the PHP version. The form-field placeholders (##tip_percent##, ##people##) and the spreadsheet outputs (##tip_amount##, ##total##, ##per_person##) all work the same way:

<div class="p-3 border rounded" style="max-width:440px">
  <div class="d-flex justify-content-between mb-2"><span>Tip (##tip_percent##%)</span><strong>##tip_amount## €</strong></div>
  <div class="d-flex justify-content-between mb-2"><span>Total to pay</span><strong>##total## €</strong></div>
  <hr>
  <div class="d-flex justify-content-between"><span>Each of ##people## pays</span><strong style="font-size:1.4rem">##per_person## €</strong></div>
</div>

8. Preferences & publish

On the Preferences tab set the button text and turn on calculate on load. Publish with a menu item of type Calc Builder and select Tip Calculator (Excel) on the Options tab.

Result

The spreadsheet-powered tip calculator

Tip 15.00 €, Total 115.00 €, 57.50 € each — identical to the PHP version, and it recalculates on every change. The whole calculation now lives in a 5 KB file that anyone can open in Excel or LibreOffice, edit, and re-upload — no developer required.

The same technique with a bigger model: a loan calculator with an amortization schedule (Excel spreadsheet).

...
Support/development 10 hours

Get a bigger amount of hours for more complex tasks and get a 10% discount

Buy now!
...
CalcBuilder

Create dynamic calculators

Buy now!