# Cells and Ranges

> Write typed values and formulas through cell and range handles, read calculated results in JavaScript or .NET and add hyperlinks in the browser editor.

- **Product:** TX Sheet Control
- **Section:** Documentation
- **Kind:** Topic
- **Path:** TX Sheet Control > Spreadsheet Documents > Cells and Ranges
- **1520 words**
- **Web URL:** https://docs.textcontrol.com/tx-sheet-control/spreadsheets/cells/
- **LLMs URL:** https://docs.textcontrol.com/tx-sheet-control/spreadsheets/cells/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-sheet-control/spreadsheets/cells/llms-full.txt

---

Cells and ranges are the handles through which you write values, text and formulas into a worksheet and read the results. Resolve the worksheet before a cell or range. A range belongs to that worksheet even when another sheet becomes active.

### Write Values and Formulas

The following code writes two invoice items into `A1:C3` of the first worksheet, then calculates the amount of each item and their total. `editor` is the [`Spreadsheet`](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/spreadsheet/llms-full.txt) of the browser editor:

```javascript
const sheet = editor.workbook.sheets.at(0);
sheet.range('A1:C3').setValues([
    ['Item', 'Quantity', 'Price'],
    ['Hardware', 2, 120], ['Software', 3, 80]
]);

sheet.cell('D2').setFormula('=B2*C2');
sheet.cell('D3').setFormula('=B3*C3');
sheet.cell('D4').setFormula('=SUM(D2:D3)');
console.log(sheet.cell('D4').value); // 480
```

The code works as follows:

- [`Workbook.sheets`](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/workbook/sheets-property/llms-full.txt) and [`SheetCollection.at`](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/sheetcollection/at-method/llms-full.txt) resolve the first worksheet before any cell or range.
- [`Worksheet.range`](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/worksheet/range-method/llms-full.txt) creates a handle for the range `A1:C3`, and [`Range.setValues`](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/range/setvalues-method/llms-full.txt) writes a typed matrix into it. When you assign multiple values, use a rectangular two-dimensional array.
- [`Worksheet.cell`](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/worksheet/cell-method/llms-full.txt) creates a cell handle, and [`Cell.setFormula`](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/cell/setformula-method/llms-full.txt) writes a formula. The leading equals sign is required.
- [`Cell.value`](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/cell/value-property/llms-full.txt) returns the calculated value of the total in `D4`.

### How Input, Value and Display Differ

A cell keeps three layers of its content apart:

- **Input.** The entered input may be a formula or literal text.
- **Value.** The calculated value is a scalar, an error or an array result.
- **Display.** The formatted display adds the number, date or text presentation.

Write each kind of content with its own method:

| Method | Use it for | What it does |
|---|---|---|
| [`setValue()`](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/cell/setvalue-method/llms-full.txt) | Typed values | Writes a literal scalar. Strings are not interpreted as formulas. |
| [`setText()`](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/cell/settext-method/llms-full.txt) | Literal text | Preserves leading zeros and leading equals signs. |
| [`setFormula()`](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/cell/setformula-method/llms-full.txt) | A formula expression | Requires the leading equals sign. |

Avoid interpreting a formatted currency string as a numeric result.

The .NET API follows the same distinction through asynchronous cell methods. [`GetValueAsync()`](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/cell/getvalueasync-method/llms-full.txt) returns JSON data, a `JsonElement`, not a locale-formatted display string. Inspect the JSON value kind before reading a number, string or boolean.

### Read and Write Whole Ranges

Range APIs read and write matrices, assign formulas and inputs, format and clear cells, merge and unmerge them and perform the supported fill and copy operations:

| Task | Members of `Range` |
|---|---|
| Read and write matrices | [`read`](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/range/read-method/llms-full.txt), [`values`](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/range/values-property/llms-full.txt), [`setValues`](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/range/setvalues-method/llms-full.txt) |
| Assign formulas and inputs | [`setFormulas`](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/range/setformulas-method/llms-full.txt), [`setInputs`](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/range/setinputs-method/llms-full.txt) |
| Format and clear | [`format`](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/range/format-method/llms-full.txt), [`clear`](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/range/clear-method/llms-full.txt) |
| Merge and unmerge | [`merge`](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/range/merge-method/llms-full.txt), [`unmerge`](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/range/unmerge-method/llms-full.txt) |
| Fill and copy | [`fillTo`](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/range/fillto-method/llms-full.txt), [`copyTo`](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/range/copyto-method/llms-full.txt) |

Array dimensions must match the target operation. Worksheet bounds, protection and merged cells can restrict edits. Validate the full rectangle before you apply business updates.

### Address Cells and Ranges

Use A1 strings such as `B2`, rectangles such as `A1:D20` or supported coordinate objects. Coordinate row and column indices are zero-based.

Named ranges can make templates more readable. Formula references can span sheets and use absolute or relative coordinates, while a range handle itself represents a rectangle on one sheet.

### Add a Hyperlink in the Editor

Select a cell and choose **Insert → Hyperlink**. Open **Link Settings**, then enter the **Link Target**, **Text to Display** and optional **ScreenTip**. The range picker beside the target helps select a worksheet reference.

![Insert Hyperlink with target, display text and ScreenTip rows in the Link Settings section](https://docs.textcontrol.com/assets/img/tx-sheet-control/hyperlink-dialog.25f0f89a.webp)

Choose **Apply** to store the link or **Cancel** to discard the draft. **Remove Hyperlink** removes an existing cell link. The dialog uses the shared fixed frame and aligned fields; it does not add a separate preview for these text settings.

### Next Steps

- [Formulas](https://docs.textcontrol.com/tx-sheet-control/spreadsheets/formulas/llms-full.txt): write formulas with references and dynamic arrays and handle their errors.
- [Formatting and Number Display](https://docs.textcontrol.com/tx-sheet-control/spreadsheets/formatting/llms-full.txt): change how values are displayed without changing them.
- [Named Ranges and External References](https://docs.textcontrol.com/tx-sheet-control/spreadsheets/named-ranges/llms-full.txt): give ranges and constants names that formulas and templates use.
- [Data Validation](https://docs.textcontrol.com/tx-sheet-control/spreadsheets/validation/llms-full.txt): constrain the input users can enter into cells.

---

## Nearby

- **Previous:** [Workbooks and Worksheets](https://docs.textcontrol.com/tx-sheet-control/spreadsheets/workbooks/llms-full.txt)
- **Next:** [Rows and Columns](https://docs.textcontrol.com/tx-sheet-control/spreadsheets/rows-columns/llms-full.txt)
