跳至页脚内容
使用 IRONXL

如何在 Excel 中将表格转换为范围

An Excel table provides a list of features that are used to effectively analyze and manage data, such as auto-filter and sort options, total row, calculated columns, table style, automatic expansion, etc.

The screenshot below shows a difference between a normal range and a table style formatting:

How to Convert Table to Range in Excel - Figure 1: Normal Range
How to Convert Table to Range in Excel - Figure 2: Table Format

This tutorial will demonstrate how to convert an Excel table to a range.

How to Create a Table?

There are many ways to create or convert a range to a table range in Excel. To insert a table in Excel, click any single cell within your data set, and do any of the following:

  1. On the Insert menu tab, in the Tables section group, click the Table option. A default style table will be inserted.

    How to Convert a Table to a Range in Excel, Figure 3: Insert a New Table in Excel with Default Styles Insert a New Table in Excel with Default Styles

  2. On the Home menu tab, in the Styles section group, click Format as Table, and select one of the predefined table styles. You can choose any banded rows style.

    How to Convert a Table to a Range in Excel, Figure 4: Apply a predefined format to an existing Excel spreadsheet table Apply a predefined format to an existing Excel spreadsheet table

  3. Another option and the fastest way to create an Excel table is by pressing the keyboard shortcut: Ctrl + T.

Whichever method you choose, the Create Table dialog box appears. Excel automatically selects the data range. Verify the selected range, then check/uncheck the "My table has headers" option, and click OK.

How to Convert a Table to a Range in Excel, Figure 5: Format the Table with Excel preselected style Format the Table with Excel preselected style

As a result, a nicely formatted table is created in the worksheet.

The filter arrows allow us to filter and sort the data in the table based on your criteria. While scrolling, the column headers box is visible. New data can be included using automatic table expansion, Quick totals, Calculating table data with ease are some prominent table features.

Now we know how to convert a regular range of cells to a table style. At some point, we might need to remove table formatting and convert the table to a normal range without losing any data and formulas. So let's have a look at how to convert an Excel table to a range.

How to Convert Table Style to a Normal Range?

There are two ways to convert a table to a cell range in Excel.

If you want to remove a table without losing the table data, table formatting, or structured references, you can follow the below steps:

  1. Go to the Table Design tab under Table Tools > Tools group, and click Convert to Range.

    How to Convert a Table to a Range in Excel, Figure 6: Converting a Styled Table into a Normal Range using the Menu Bar options Converting a Styled Table into a Normal Range using the Menu Bar options

  2. Alternatively, right-click anywhere within the table, and click Table > Convert to Range.

    How to Convert a Table to a Range in Excel, Figure 7: Converting a Styled Table into a Normal Range using the Context Menu Converting a Styled Table into a Normal Range using the Context Menu

This is how you can convert the data of a table to a range. Notice that the arrows are removed from the range but the data and formatting are preserved.

How to Convert a Table to a Range in Excel, Figure 8: The appearance of the spreadsheet data, after being converted back to a Normal range The appearance of the spreadsheet data, after being converted back to a Normal range

The IronXL C# Library

IronXL is a .NET library that facilitates reading and editing Microsoft Excel documents with C# without Microsoft Excel or Interop. IronXL can read and manipulate Excel files with accuracy and fast performance. It supports all .NET components, along with platforms such as Android, Xamarin, Linux, Azure, AWS, macOS, Docker, and MAUI.

With a few lines of code, developers can perform all Excel-related tasks without any complication. These tasks include adding two cells, adding rows and columns of data to Excel tables, and applying functions across rows and columns, among others.

IronXL Feature Set

  • Load, read, and edit data — from XLS/XLSX/CSV/TSV
  • Saving and exporting — to XLS/XLSX/CSV/TSV/JSON
  • System.Data Objects — work with Excel Spreadsheets as System.Data.DataSet and System.Data.DataTable objects.
  • Formulas — works with Excel formulas. Formulas get recalculated whenever the sheet is edited.
  • Ranges — easy to use ["A1:B10"] syntax.
  • Sorting — it can sort rows, columns, and ranges within a table or normal range.
  • Styling — font, font size, cell style, alignments, background color, and many more styling options are available.

Below are some code examples of C# code to manipulate Excel files:

using IronXL;

public class ExcelExample
{
    public static void Main()
    {
        // Load an existing Excel workbook
        WorkBook workbook = WorkBook.Load("test.xlsx");

        // Choose the default worksheet in the workbook
        WorkSheet worksheet = workbook.DefaultWorkSheet;

        // Set formulas for various cells
        worksheet["A1"].Formula = "SUM(B8:C12)"; // Sum cells B8 to C12
        worksheet["B8"].Formula = "=C9/C11"; // Divide value in C9 by value in C11
        worksheet["G30"].Formula = "MAX(C3:C7)"; // Find the maximum value from cells C3 to C7

        // Force recalculating all formulas in all sheets
        workbook.EvaluateAll();

        // Retrieve calculated value from a cell
        string formulaValue = worksheet["G30"].Value.ToString(); // e.g., 52

        // Retrieve the formula as a string from a cell
        string formulaString = worksheet["G30"].Formula; // e.g., "MAX(C3:C7)"

        // Save changes with updated formulas and calculated values
        workbook.Save();
    }
}
using IronXL;

public class ExcelExample
{
    public static void Main()
    {
        // Load an existing Excel workbook
        WorkBook workbook = WorkBook.Load("test.xlsx");

        // Choose the default worksheet in the workbook
        WorkSheet worksheet = workbook.DefaultWorkSheet;

        // Set formulas for various cells
        worksheet["A1"].Formula = "SUM(B8:C12)"; // Sum cells B8 to C12
        worksheet["B8"].Formula = "=C9/C11"; // Divide value in C9 by value in C11
        worksheet["G30"].Formula = "MAX(C3:C7)"; // Find the maximum value from cells C3 to C7

        // Force recalculating all formulas in all sheets
        workbook.EvaluateAll();

        // Retrieve calculated value from a cell
        string formulaValue = worksheet["G30"].Value.ToString(); // e.g., 52

        // Retrieve the formula as a string from a cell
        string formulaString = worksheet["G30"].Formula; // e.g., "MAX(C3:C7)"

        // Save changes with updated formulas and calculated values
        workbook.Save();
    }
}
Imports IronXL

Public Class ExcelExample
	Public Shared Sub Main()
		' Load an existing Excel workbook
		Dim workbook As WorkBook = WorkBook.Load("test.xlsx")

		' Choose the default worksheet in the workbook
		Dim worksheet As WorkSheet = workbook.DefaultWorkSheet

		' Set formulas for various cells
		worksheet("A1").Formula = "SUM(B8:C12)" ' Sum cells B8 to C12
		worksheet("B8").Formula = "=C9/C11" ' Divide value in C9 by value in C11
		worksheet("G30").Formula = "MAX(C3:C7)" ' Find the maximum value from cells C3 to C7

		' Force recalculating all formulas in all sheets
		workbook.EvaluateAll()

		' Retrieve calculated value from a cell
		Dim formulaValue As String = worksheet("G30").Value.ToString() ' e.g., 52

		' Retrieve the formula as a string from a cell
		Dim formulaString As String = worksheet("G30").Formula ' e.g., "MAX(C3:C7)"

		' Save changes with updated formulas and calculated values
		workbook.Save()
	End Sub
End Class
$vbLabelText   $csharpLabel

IronXL helps developers to rely on simple yet high-performance code with accuracy and efficiency, which helps reduce the risk of error and makes it easier to manipulate Excel files programmatically.

You can download the IronXL software product and try it for free.

常见问题解答

如何在 Excel 中将表格转换为范围?

要将 Excel 中的表格转换为范围,导航到表格工具下的表格设计选项卡,并选择“转换为范围”。或者,可以右键单击表格内,选择“表格”,然后“转换为范围”。这将删除表格的结构化引用和格式化,同时保留数据。

使用 Excel 表格有何好处?

Excel 表格提供自动过滤、排序选项、自动扩展、计算列和表格样式等特点,有助于有效分析和管理数据。

如何使用键盘快捷键在 Excel 中创建表格?

在 Excel 中,您可以通过在数据集中选择单个单元格并按 Ctrl + T 来创建表格。这将打开创建表格对话框,让您以表格格式化数据。

IronXL 如何协助编程操作 Excel 文件?

IronXL 是一个.NET 库,允许开发者使用 C# 来有效地读取、编辑和操作 Excel 文档,无需使用 Microsoft Excel。它提供添加行、应用函数和单元格样式等功能。

IronXL 能够处理各种 Excel 文件格式吗?

是的,IronXL 可以加载、读取和编辑 XLS、XLSX、CSV 和 TSV 文件的数据。它还允许保存和导出为这些格式以及 JSON。

是否可以在云环境中使用 IronXL 操作 Excel 文件?

是的,IronXL 支持在 Azure 和 AWS 等云平台中操作 Excel 文件。它还在 Android、Xamarin、Linux、macOS、Docker 和 MAUI 等环境中运行。

IronXL 为 Excel 文件提供哪些样式选项?

IronXL 提供多种样式选项,包括字体类型和大小、单元格样式、对齐和背景色,允许自定义 Excel 电子表格。

为什么要将表格转换为 Excel 中的范围?

将表格转换为范围在想要通过去除自动过滤、排序和格式化等表格功能来简化数据管理过程时很有用,同时保留数据和基础公式。

IronXL 如何增强 Excel 文件操作?

IronXL 通过提供一种简单且高效的方式与 Excel 文档进行编程交互,提供公式支持、数据加载、导出和广泛的样式选项来增强 Excel 文件操作。

Curtis Chau
技术作家

Curtis Chau 拥有卡尔顿大学的计算机科学学士学位,专注于前端开发,精通 Node.js、TypeScript、JavaScript 和 React。他热衷于打造直观且美观的用户界面,喜欢使用现代框架并创建结构良好、视觉吸引力强的手册。

除了开发之外,Curtis 对物联网 (IoT) 有浓厚的兴趣,探索将硬件和软件集成的新方法。在空闲时间,他喜欢玩游戏和构建 Discord 机器人,将他对技术的热爱与创造力相结合。