# Getting Started with TX Sheet Control in ASP.NET Core

> Build your first ASP.NET Core spreadsheet application with TX Sheet Control. Configure the license, editor areas, and ribbon, load XLSX files and CSV data, and use getControl to change cell text, values, and formulas. Includes a complete sample application.

- **Author:** Bjoern Meyer
- **Published:** 2026-12-02
- **Modified:** 2026-12-02
- **Description:** Build your first ASP.NET Core spreadsheet application with TX Sheet Control. Configure the license, editor areas, and ribbon, load XLSX files and CSV data, and use getControl to change cell text, values, and formulas. Includes a complete sample application.
- **11 min read** (2168 words)
- **Tags:**
  - Spreadsheet
  - ASP.NET Core
  - .NET
  - JavaScript
  - Getting Started
- **Web URL:** https://www.textcontrol.com/blog/2026/12/02/getting-started-with-tx-sheet-control-in-aspnet-core/
- **LLMs URL:** https://www.textcontrol.com/blog/2026/12/02/getting-started-with-tx-sheet-control-in-aspnet-core/llms.txt
- **LLMs-Full URL:** https://www.textcontrol.com/blog/2026/12/02/getting-started-with-tx-sheet-control-in-aspnet-core/llms-full.txt
- **GitHub Repository:** https://github.com/TextControl/TXSheetControl-AspNetCore.GettingStarted

---

TX Sheet Control adds a spreadsheet editor to an ASP.NET Core web application with a single Razor Tag Helper. In this tutorial, we create an MVC application, configure the license and editor areas, customize the ribbon, load workbooks, and use the JavaScript API to write text, numbers, and formulas into cells.

The sample uses **.NET 10** and **TX Sheet Control 2.0.0**. The ASP.NET Core package includes the browser editor and its fonts. This application does not require the separate server processing package.

![TX Sheet Control in ASP.NET Core with a compact ribbon and a calculated total of 240](https://s1-www.textcontrol.com/assets/dist/blog/2026/12/02/a/assets/first-steps.webp "TX Sheet Control in ASP.NET Core with a compact ribbon and a calculated total of 240") The sample loads worksheet data and changes cells through the JavaScript API. The compact ribbon hides Reporting and Italic and disables Clipboard.

### Create the ASP.NET Core Application

Create an ASP.NET Core Web App (Model-View-Controller) targeting .NET 10. From the command line, run:

First configure the Text Control private NuGet feed with the `nuget.config` supplied with your download, or use the supplied local NuGet folder. See [Download TX Sheet Control](https://docs.textcontrol.com/tx-sheet-control/installation/download/) for the package and license download steps.

```
dotnet new mvc -n TXSheetControlGettingStarted -f net10.0
cd TXSheetControlGettingStarted
dotnet add package TXTextControl.TXSheetControl.AspNetCore --version 2.0.0
```

### Configure the Application and Register the Tag Helper

Replace `Program.cs` with the following code. The MVC services and route serve the view. `UseStaticWebAssets` enables the package assets, and `UseTXSheetControlAssets` adds the editor asset middleware before static assets are served.

```
using TXTextControl.TXSheetControl.AspNetCore;

var builder = WebApplication.CreateBuilder(args);
builder.WebHost.UseStaticWebAssets();
builder.Services.AddControllersWithViews();

var app = builder.Build();

if (!app.Environment.IsDevelopment())
{
    app.UseExceptionHandler("/Home/Error");
    app.UseHsts();
}

app.UseHttpsRedirection();
app.UseRouting();
app.UseAuthorization();
app.UseTXSheetControlAssets();
app.MapStaticAssets();

app.MapControllerRoute(
    name: "default",
    pattern: "{controller=Home}/{action=Index}/{id?}")
    .WithStaticAssets();

app.Run();
```

Keep the standard MVC imports in `Views/_ViewImports.cshtml` and add this registration:

```
@addTagHelper *, TXTextControl.TXSheetControl.AspNetCore
```

The Tag Helper includes its browser script and initializer automatically, once per page. The editor installs its bundled styles inside its Shadow DOM. No manual references to the package scripts or stylesheet are required.

### Create an Instance with Options

Copy your `tx-sheet-control.license` file into the application root, beside `Program.cs`. Then replace `Views/Home/Index.cshtml` with this view:

```
@using TXTextControl.TXSheetControl.AspNetCore
@inject Microsoft.AspNetCore.Hosting.IWebHostEnvironment HostEnvironment
@{
    ViewData["Title"] = "TX Sheet Control: First Steps";

    var options = new TXSheetControlOptions
    {
        License = System.IO.File.ReadAllText(System.IO.Path.Combine(
            HostEnvironment.ContentRootPath, "tx-sheet-control.license")),
        Theme = "light",
        Language = "en",
        Locale = "en-US",
        Rows = 100,
        Columns = 20,
        Areas = new TXSheetControlAreas
        {
            Ribbon = true,
            FormulaBar = true,
            SheetTabs = true,
            StatusBar = true
        },
        Ribbon = new
        {
            layout = "compact",
            displayMode = "expanded",
            tabs = new Dictionary<string, object>
            {
                ["reporting"] = new { visible = false }
            },
            groups = new Dictionary<string, object>
            {
                ["home.clipboard"] = new { enabled = false }
            },
            buttons = new Dictionary<string, object>
            {
                ["home.font.italic"] = new { visible = false }
            }
        }
    };
}

<script src="~/js/first-steps.js" asp-append-version="true"></script>
<tx-sheet-control id="spread" height="600" options="options" />
```

The `License` option receives the complete contents of the license file. The sample resolves the path from the application content root. Include the file at that location when deploying, or supply the same text through your application configuration. The browser editor receives the license through its options; never include your actual license in a shared sample.

The other options configure the initial editor:

- **Appearance and locale:** `Theme` selects `light`, `dark`, or `auto`. `Language` selects the UI language, while `Locale` controls number and date formatting.
- **Worksheet capacity:** `Rows` and `Columns` set the initial capacity. They do not limit how many populated rows a loaded workbook contains.
- **Editor areas:** `Areas` shows or hides the ribbon, formula bar, sheet tabs, and status bar independently. Set a property to `false` to hide that area.
- **Host size:** The Tag Helper's `height="600"` sets the editor host height in CSS pixels. The ID `spread` identifies this instance in JavaScript.

#### Customize the Ribbon

`Ribbon` accepts a JavaScript-style configuration object. Use camelCase names inside this object, as shown above. The example chooses the compact layout, hides the Reporting tab, disables the Clipboard group, and hides the Italic button.

Ribbon item IDs are independent of the UI language. After initialization, inspect `control.ui.ribbon.items` for the catalog. For the full group layout, use `layout = "classic"`; for a collapsed command area, use `displayMode = "tabs-only"`. Ribbon settings survive document loads. Hiding or disabling a ribbon command controls the UI; it does not restrict workbook API calls.

![ASP.NET Core sample with the compact ribbon, formula bar, sheet tabs, and status bar visible](https://s1-www.textcontrol.com/assets/dist/blog/2026/12/02/a/assets/editor-options.webp "ASP.NET Core sample with the compact ribbon, formula bar, sheet tabs, and status bar visible") The initialized editor uses the configured areas and compact ribbon. Reporting and Italic are hidden, Clipboard is disabled, and the ready handler writes the greeting into A1.

### Wait for the Editor and Access the API

The Tag Helper initializes the editor asynchronously. Register a `txsheetcontrolready` listener during page loading. Its `event.detail` contains the initialized spreadsheet instance. The ID check keeps the handler specific to this editor when a page contains several controls.

Create `wwwroot/js/first-steps.js` with the following code. It writes the first text into A1 and handles initialization failures:

```
document.addEventListener('txsheetcontrolready', event => {
    if (event.target.id !== 'spread') {
        return;
    }
    const control = event.detail;
    control.workbook.sheets.at(0).cell('A1').setText('Hello from TX Sheet Control');
});

document.addEventListener('txsheetcontrolerror', event => {
    if (event.target.id === 'spread') {
        console.error('The editor could not start.', event.detail);
    }
});
```

Load this application script before the Tag Helper, as the view does, so its listeners are in place before initialization finishes. Later, for example in a button handler, obtain the same instance with `getControl`. It accepts either the host ID or the host element and returns `undefined` if no instance is registered. Add this helper to the same JavaScript file:

```
async function getSpreadsheet() {
    const control = TXTextControl.TXSheetControl.getControl('spread');
    if (!control) {
        throw new Error('The spreadsheet has not been created yet.');
    }
    await control.ready;
    return control;
}
```

`getControl` locates the instance; it does not wait for initialization. Await `control.ready` before accessing the workbook. The complete sample also keeps its action buttons disabled until the ready event.

### Load Documents

Call the editor's asynchronous `load` method with the document data and a `StreamType`. The format selector tells the API how to interpret the input. In the Tag Helper integration, these types are available through `TXTextControl.TXSheetControl.StreamType`.

#### Load an XLSX from the Application

Place an XLSX file at `wwwroot/documents/first-steps.xlsx`. Add a button to the view above the script and editor:

```
<button id="load-template" type="button"
        data-url="@Url.Content("~/documents/first-steps.xlsx")">Load sample XLSX</button>
```

`Url.Content` resolves the URL relative to the application, including when it is hosted under a virtual path. Fetch the bytes, check the HTTP response, and load them as `SpreadsheetML`, the stream type for XLSX:

```
document.getElementById('load-template').addEventListener('click', async event => {
    const url = event.currentTarget.dataset.url;
    try {
        const control = await getSpreadsheet();
        const response = await fetch(url);
        if (!response.ok) {
            throw new Error(`Could not load the sample workbook (HTTP ${response.status}).`);
        }
        const bytes = new Uint8Array(await response.arrayBuffer());
        const result = await control.load(bytes, TXTextControl.TXSheetControl.StreamType.SpreadsheetML);
        result.warnings.forEach(warning => console.warn(warning));
    } catch (error) {
        console.error('Loading the workbook failed.', error);
    }
});
```

![Sample XLSX loaded into the Orders worksheet with item, quantity, and unit price columns](https://s1-www.textcontrol.com/assets/dist/blog/2026/12/02/a/assets/workbook-loaded.webp "Sample XLSX loaded into the Orders worksheet with item, quantity, and unit price columns") Load sample XLSX reads the workbook from the application and displays its Orders worksheet. The status area reports the conversion notice returned by the load operation.

#### Open a Local XLSX File

A file selected by the user supplies the same bytes through `File.arrayBuffer()`. Add this input above the application script:

```
<input id="open-workbook" type="file" accept=".xlsx" />
```

Then add its change handler to `first-steps.js`. This reads the selected file in the browser:

```
document.getElementById('open-workbook').addEventListener('change', async event => {
    const input = event.target;
    const file = input.files[0];
    if (!file) {
        return;
    }
    try {
        const control = await getSpreadsheet();
        const bytes = new Uint8Array(await file.arrayBuffer());
        const result = await control.load(bytes, TXTextControl.TXSheetControl.StreamType.SpreadsheetML);
        result.warnings.forEach(warning => console.warn(warning));
    } catch (error) {
        console.error('Opening the workbook failed.', error);
    } finally {
        input.value = '';
    }
});
```

#### Load CSV Text

CSV can be loaded directly from a string. Add a `<button id="load-csv" type="button">Load CSV</button>` above the script, then register this handler:

```
document.getElementById('load-csv').addEventListener('click', async () => {
    try {
        const control = await getSpreadsheet();
        const csv = 'Item,Quantity,Unit price\nConsulting,2,120\nTraining,3,80';
        const result = await control.load(csv, TXTextControl.TXSheetControl.StreamType.CSV, {
            sheetName: 'Orders',
            delimiter: ',',
            decimalSeparator: '.'
        });
        result.warnings.forEach(warning => console.warn(warning));
    } catch (error) {
        console.error('Loading CSV failed.', error);
    }
});
```

CSV imports replace the workbook with one worksheet containing the tabular values. For complete workbook files, use XLSX, `StreamType.OpenDocumentSpreadsheet` for ODS, or `StreamType.InternalWorkbookFormat` for TXWB. PDF is an export format.

Always await a load before editing the new document, inspect `result.warnings`, and handle rejected promises. Loading replaces the document, so reacquire worksheet, range, and cell handles afterward. A conversion warning can accompany a successful load; the sample workbook, for example, reports that custom document properties are retained in the original package but are not projected into the native model.

### Change Cell Text, Values, and Formulas

Add a `<button id="update-cells" type="button">Update cells</button>` above the script. Its handler retrieves the current editor, acquires the first worksheet, and writes a small calculation:

```
document.getElementById('update-cells').addEventListener('click', async () => {
    try {
        const control = await getSpreadsheet();
        const sheet = control.workbook.sheets.at(0);
        sheet.cell('A1').setText('Service');
        sheet.cell('B1').setText('Quantity');
        sheet.cell('C1').setText('Unit price');
        sheet.cell('D1').setText('Total');
        sheet.cell('A2').setText('Consulting');
        sheet.cell('B2').setValue(2);
        sheet.cell('C2').setValue(120);
        sheet.cell('D2').setFormula('=B2*C2');
        sheet.range('A1:D1').format({ bold: true, fillColor: '#e5eef4' });
        sheet.range('C2:D2').format({ numberFormatCode: '#,##0.00' });
        sheet.columns.at(0).setWidth({ pixels: 160 });
        sheet.columns.at(1).setWidth({ pixels: 100 });
        sheet.columns.at(2).setWidth({ pixels: 120 });
        sheet.columns.at(3).setWidth({ pixels: 100 });
        console.log(sheet.cell('D2').value); // 240
    } catch (error) {
        console.error('Updating cells failed.', error);
    }
});
```

`setText` writes literal text, including leading zeros or a leading equals sign. `setValue` writes a typed scalar such as a number. `setFormula` writes a formula with its leading equals sign. Read a cell's calculated result through `value`, its formatted display through `displayText`, and its formula through `formula`.

Here, B2 contains 2 and C2 contains 120, so D2 calculates 240 and displays **240.00**. The range API formats the header and numeric cells, while the column API sets readable widths.

![Cell D2 selected with formula =B2*C2 in the formula bar and the calculated result 240.00 in the worksheet](https://s1-www.textcontrol.com/assets/dist/blog/2026/12/02/a/assets/api-cell-formula.webp "Cell D2 selected with formula =B2*C2 in the formula bar and the calculated result 240.00 in the worksheet") After Update cells, D2 contains =B2\*C2 and displays 240.00. Selecting D2 shows the formula in the formula bar, while the header formatting and column widths come from the API calls.

### Run the Complete Sample

Download the complete ASP.NET Core sample. It includes the view, JavaScript, and sample XLSX. Add your own `tx-sheet-control.license` beside `Program.cs` and configure your NuGet source before running `dotnet run`.

Try **Load CSV**, **Open local XLSX**, or **Load sample XLSX**, then select **Update cells**. The complete sample disables its actions during initialization and loading, displays errors in a status area, and reports conversion warnings. The code above shows each operation individually.

Continue with the [ASP.NET Core integration guide](https://docs.textcontrol.com/tx-sheet-control/getting-started/spreadsheet-editor/aspnet-core/), the [loading and saving guide](https://docs.textcontrol.com/tx-sheet-control/document-processing/load-save/), and the [JavaScript API reference](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/).

[Download trial](https://www.textcontrol.com/product/tx-sheet-control/download/trial/ "Download Trial")

### Frequently Asked Questions

Which .NET version does the ASP.NET Core package require? 
----------------------------------------------------------

TXTextControl.TXSheetControl.AspNetCore 2.0.0 requires .NET 10 or newer. It includes the browser editor and its static fonts and works independently of the server processing package.

How do I configure the license and visible editor areas? 
---------------------------------------------------------

Pass the complete contents of tx-sheet-control.license through TXSheetControlOptions.License. Use Areas.Ribbon, Areas.FormulaBar, Areas.SheetTabs, and Areas.StatusBar to show or hide the editor areas.

Can I customize the ribbon from Razor? 
---------------------------------------

Yes. TXSheetControlOptions.Ribbon accepts a camelCase configuration object for the layout, displayMode, tabs, groups, and buttons. Item IDs are language-independent, and settings survive document loads.

When can I call getControl and edit cells? 
-------------------------------------------

Use the instance in the txsheetcontrolready event or retrieve it with TXTextControl.TXSheetControl.getControl using the host ID or element. Check that the instance exists and await control.ready before accessing its workbook.

How do I load an XLSX file? 
----------------------------

Read the file into a Uint8Array or ArrayBuffer and await control.load with StreamType.SpreadsheetML. Inspect the returned conversion warnings and reacquire worksheet, range, and cell handles after loading the new document.

---

## About Bjoern Meyer

As CEO, Bjoern is the visionary behind our strategic direction and business development, bridging the gap between our customers and engineering teams. His deep passion for coding and web technologies drives the creation of innovative products. If you're at a tech conference, be sure to stop by our booth - you'll most likely meet Bjoern in person. With an advanced graduate degree (Dipl. Inf.) in Computer Science, specializing in AI, from the University of Bremen, Bjoern brings significant expertise to his role. In his spare time, Bjoern enjoys running, paragliding, mountain biking, and playing the piano.

- [LinkedIn](https://www.linkedin.com/in/bjoernmeyer/)
- [X](https://x.com/txbjoern)
- [GitHub](https://github.com/bjoerntx)

---

## Related Posts

- [TX Sheet Control 2.0 Is Now Available: Spreadsheets and Dashboards for Your Applications](https://www.textcontrol.com/blog/2026/12/01/tx-sheet-control-2-0-is-now-available/llms.txt)
- [Getting Started with TX Sheet Control in Blazor WebAssembly](https://www.textcontrol.com/blog/2026/12/02/getting-started-with-tx-sheet-control-in-blazor-webassembly/llms.txt)
- [Getting Started with TX Sheet Control in Blazor Server](https://www.textcontrol.com/blog/2026/12/02/getting-started-with-tx-sheet-control-in-blazor-server/llms.txt)
- [Inside the TX Sheet Control Spreadsheet Editor: A Complete Spreadsheet for Your Web Applications](https://www.textcontrol.com/blog/2026/12/01/inside-the-tx-sheet-control-spreadsheet-editor/llms.txt)
- [How to Embed a DOCX Editor in a Web Application (ASP.NET Core)](https://www.textcontrol.com/blog/2026/10/30/how-to-embed-docx-editor-aspnet-core/llms.txt)
- [Getting Started: Document Viewer with JavaScript](https://www.textcontrol.com/blog/2023/09/15/getting-started-document-viewer-with-javascript/llms.txt)
- [Getting Started: Document Editor with JavaScript](https://www.textcontrol.com/blog/2023/09/15/getting-started-document-editor-with-javascript/llms.txt)
