# Excel: Calculations and logic with account files

URL: https://help.hubhus.com/kb/excel-calculations-account-files
Category: User & Account Management / Files
Updated: 2026-09-28T14:41:10.382+00:00

Summary: Upload an .xlsx under Account → Web & Resources → Files . Reference it with &lt;hh-excel.cell file="slug" get="C2" set="A1:{{field}}" /> . Prefer action listeners that write results into Hubhus fields (background) - avoid running Excel on the page load path. If a page display is required, wrap the Excel/calculator block in &lt;hh-html.fragment async> so the rest of the page loads first. Clear input cells before every file replace. See Account files .

Use an Excel workbook stored as an Account file as your calculation engine. Hubhus writes lead/form values into cells with `<hh-excel.cell>`, Excel runs the formulas, and Hubhus reads the result - for booking duration, live price displays, or action listeners that write values into lead fields.

## Get started in 4 steps

1. **Prepare and upload the workbook**. Build formulas in Excel as usual. Decide which cells are **inputs** (Hubhus will write these) and which cell is the **output** (Hubhus will read it). **Clear demo/default values from input cells before upload** - otherwise empty Hubhus fields can leave sample numbers in the sheet and produce wrong results. Upload under **Account → Web & Resources → Files** and note the slug.
2. **Use hh-excel.cell**. Core syntax (from Hubhus placeholder docs): `<hh-excel.cell file="slug" get="C2" set="A1:42" set="A2:15" />`
  **file** = Account file slug · **sheet** = worksheet (default: first) · **get** = cell to return · **set** = `cell:value` (multiple allowed) · **debug** = output debug log when troubleshooting.
3. **Prefer fields + action listeners (background)**. **Recommended:** run Excel from an **action listener** and store results in Hubhus fields (subtotal, duration, etc.). The page then reads normal field values - no wait for Excel on every page render. **Not recommended:** calling `hh-excel.cell` directly on a Hubhus Page where the visitor must wait for the workbook. That can slow the page significantly. If you must show Excel-driven output on a page, wrap it in an async HTML fragment (see Read more).
4. **Update logic by replacing the file**. Change formulas in Excel → clear input cells again → in Account files open **Update file** → upload the new workbook on the **same slug**. Pages and listeners that use `file="your-slug"` pick up the new logic automatically. Details: [Account files: Shared assets and replaceable URLs](https://help.hubhus.com/kb/account-files-shared-assets-and-replaceable-urls).

**Prefer:** listeners → fields · **Page Excel:** only inside fragment async · **Before upload:** clear input cells

**Read more**

Performance - do not block the page on Excel

Running `hh-excel.cell` (or a calculator that contains it) directly in page HTML forces the server to open the workbook before the page finishes. That can make the page feel slow. **Always prefer** writing results into Hubhus fields via action listeners so calculations run as background work; the page only displays stored field values.

If you still need Excel output on a page, wrap the block in an async fragment so the rest of the page loads while Excel runs:

```
<hh-html.fragment async>
  @include(price-calculation)
</hh-html.fragment>
```

Put the `hh-excel.cell` / `hh-calculator` markup inside the included component (or directly inside the fragment). The page shell renders immediately; the fragment fills in when Excel is ready.

### Pattern 1 - Booking time / duration

Map questionnaire answers into Excel input cells and **get** a duration (or similar) cell. Typical use: minutes needed for a job based on meterage, wall drillings, ladder need, and so on. Wrap in `<hh-calculator>` if you also add fixed extras with `@if`.

```
<hh-calculator precision="0" thousandsSeparator=".">
<hh-excel.cell file="duration-model"
  get="E82"
  set="D3:{{panel-location}}"
  set="D24:{{meters-indoors}}"
  set="D55:{{wall-drillings}}"
  set="D77:{{needs-ladder}}" />
@if({{install-type}} == Package B){+30}@endif
</hh-calculator>
```

### Pattern 2 - Live price on a page (use only if necessary)

Prefer storing the price in a field via an action listener. If you must display an Excel result on the page, keep the calculator inside `hh-html.fragment async` (see performance note above):

```
<hh-calculator precision="0" thousandsSeparator=".">
<hh-excel.cell file="savings-model"
  get="B24"
  set="I11:{{heat-source}}"
  set="K11:{{consumption}}"
  set="J14:{{home-m2}}"
  set="J17:{{insulation}}"
  set="J23:{{desired-product}}" />
</hh-calculator> Kr.
```

### Pattern 3 - Action listeners write Hubhus fields (recommended)

Best default for production. Create an action listener (e.g. on lead created, field changed, or action button). Each action can **Set value of** a Hubhus field to an `hh-excel.cell` result - subtotal from one cell, discount from another, duration from a third - often with the same `set` map. Add requirements so the listener only runs when needed inputs exist. Pages and emails then use normal field placeholders with no Excel wait on render.

```
<!-- Example: set Subtotal from Excel cell D12 -->
<hh-excel.cell file="price-model"
  get="D12"
  set="C3:%lead_postal_code%"
  set="C6:{{driveways}}"
  set="C7:{{lawn-m2}}"
  set="C9:@if({{neighbour-discount-pct}}){{{neighbour-discount-pct}}%}@endif" />
```

See also [Understanding action listeners](https://help.hubhus.com/kb/understanding-action-listeners).

Clear inputs before every replace

Hubhus only overwrites cells you list in `set`. Values left in the uploaded workbook act as defaults when a placeholder is empty. Always empty those input cells (or set them to blank) in Excel before you Update the Account file - especially after testing with demo data.

### Troubleshooting

- Wrong result with empty fields → leftover demo values in the xlsx input cells
- Slug not found → file must be an **Account file**; check the exact slug in Files
- Unexpected sheet → set `sheet="…"` if not using the first worksheet
- Hard to debug → add `debug` temporarily

## Related articles

- https://help.hubhus.com/kb/account-files-shared-assets-and-replaceable-urls
- https://help.hubhus.com/kb/how-to-calculate-values-and-format-numbers-in-templates
- https://help.hubhus.com/kb/javascript-managing-javascript-files
- https://help.hubhus.com/kb/hh-components-reference-guide
