# Importing Excel XLSX Spreadsheets into TX Text Control in ASP.NET Core and Windows Forms in C#

> TX Text Control is able to import Excel documents by converting spreadsheets into tables. This article shows how to import spreadsheets programmatically.

- **Author:** Bjoern Meyer
- **Published:** 2023-02-07
- **Modified:** 2025-11-16
- **Description:** TX Text Control is able to import Excel documents by converting spreadsheets into tables. This article shows how to import spreadsheets programmatically.
- **2 min read** (372 words)
- **Tags:**
  - ASP.NET
  - Excel
  - Spreadsheet
  - XLSX
  - Tables
- **Web URL:** https://www.textcontrol.com/blog/2023/02/07/importing-excel-xlsx-spreadsheets-into-tx-text-control/
- **LLMs URL:** https://www.textcontrol.com/blog/2023/02/07/importing-excel-xlsx-spreadsheets-into-tx-text-control/llms.txt
- **LLMs-Full URL:** https://www.textcontrol.com/blog/2023/02/07/importing-excel-xlsx-spreadsheets-into-tx-text-control/llms-full.txt

---

All .NET products of TX Text Control including ASP.NET (Core), Windows Forms and WPF provide an Excel XLSX SpreadsheetML filter to import spreadsheets into a document. Spreadsheets included in an Excel document can be imported and converted into a "smart" table including supported formulas, cell number format settings and the included formatting.

### Importing Spreadsheets

In order to load spreadsheets from XLSX files into TX Text Control, all file load methods can be utilized including:

- Load
- Selection.Load
- Append

This allows the insertion of spreadsheets into a new document, into the current input position or at a new section or page. The spreadsheets can be loaded from physical files, byte arrays or streams.

The DocumentPartName property of the *LoadSettings* is used to define the sheet in the loaded document. The following code is loading spreadsheet *2021* from the document *cashflow.xlsx* into the current input position.

```
TXTextControl.LoadSettings ls = new TXTextControl.LoadSettings() {
  DocumentPartName = "2021"
};

textControl1.Selection.Load("cashflow.xlsx", TXTextControl.StreamType.SpreadsheetML, ls);
```

The following screenshot shows the spreadsheet *2021* opened in Microsoft Excel. This name is used in the *DocumentPartName* property.

![Spreadsheets in Excel Document](https://s1-www.textcontrol.com/assets/dist/blog/2023/02/07/a/assets/excel1.webp "Spreadsheets in Excel Document")

After importing the spreadsheet into TX Text Control, you can see the imported formatting, the table cell format and the working formulas:

![Spreadsheets in Excel Document](https://s1-www.textcontrol.com/assets/dist/blog/2023/02/07/a/assets/excel2.webp "Spreadsheets in Excel Document")

### Reference Styles

TX Text Control provides two reference styles to reference cells for formulas: **A1** and **R1C1**.

![Spreadsheets in Excel Document](https://s1-www.textcontrol.com/assets/dist/blog/2023/02/07/a/assets/excel.gif "Spreadsheets in Excel Document")

### Loading Multiple Spreadsheets

The following code shows how to load multiple spreadsheets into TX Text Control by calling the *Selection.Load* multiple times:

```
private void ImportSpreadsheets(string filename, string[] sheetNames) {

   foreach (string sheetName in sheetNames) {
      TXTextControl.LoadSettings ls = new TXTextControl.LoadSettings() {
         DocumentPartName = sheetName
      };

      textControl1.Selection.Load(filename, TXTextControl.StreamType.SpreadsheetML, ls);
   }

}

ImportSpreadsheets("cashflow.xlsx", new string[] { "2021", "2022" });
```

The following screenshot animation shows the working formulas when changing the associated cell content.

![Spreadsheets in Excel Document](https://s1-www.textcontrol.com/assets/dist/blog/2023/02/07/a/assets/excel2.gif "Spreadsheets in Excel 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

- [Loading and Processing Excel XLSX Spreadsheet Tables into TX Text Control using .NET C#](https://www.textcontrol.com/blog/2024/10/16/loading-and-processing-excel-spreadsheet-tables-into-tx-text-control-using-net-csharp/llms.txt)
- [Import and Manipulate Excel Spreadsheets by Converting Cells into Merge Fields in C#](https://www.textcontrol.com/blog/2023/08/08/import-and-manipulate-excel-spreadsheets-by-converting-cells-into-merge-fields/llms.txt)
