跳至页脚内容
使用 IRONXL

如何在 Excel 中取消隐藏所有行

1.0 Introduction

Hiding rows in Excel is beneficial for focusing on essential information, concealing sensitive data, and managing large documents. Unhiding all rows and columns is crucial for modifying sheets and understanding dependencies in inherited spreadsheets. This article will cover both options using the IronXL library for productivity and programmatic control.

2.0 Hiding Rows in Excel

Rows can be hidden in Excel using the ribbon button, the right-click menu, or a keyboard shortcut, as with most basic actions in Excel.

To hide rows, start by selecting the rows you want to hide:

  • Click on a row's heading to select it.
  • Drag the mouse across the row headings to select multiple adjacent rows. Alternatively, select the last row while holding down the Shift key after selecting the first row.
  • Hold down the Ctrl key while clicking on the headings of additional rows you want to select when choosing non-contiguous rows by selecting the first row's heading first.

After selecting the rows, choose one of the following options:

2.1 Hiding Rows Using Ribbon Button

It is also possible to hide rows in Excel using the Ribbon button located at the top of the Excel sheet.

Step 1: Click the Format button in the Cells group under the Home tab.

Step 2: Choose Hide Rows from the Hide & Unhide menu under Visibility.

How to Unhide All Rows in Excel, Figure 1: Excel Hide & Unhide Excel Hide & Unhide

As another option, you can select Home > Format > Row Height and enter 0 in the field for Row Height. In either case, the selected rows will immediately be hidden from view.

2.2 Hiding Rows Using the Right-Click Menu

If you don't want to search for the Hide command on the ribbon, you can access it from the context menu by right-clicking on the column or row header and choosing the Hide option.

How to Unhide All Rows in Excel, Figure 2: Hide in the context menu Hide in the context menu

2.3 Hiding Rows Using Keyboard Shortcut

A keyboard shortcut can also be used to hide rows in an Excel document by pressing Ctrl + 9 to hide all rows.

3.0 Unhiding Rows in Excel

Hidden rows can be unhidden using the ribbon button, right-click menu, or keyboard shortcut, as with most basic actions in Excel.

3.1 Unhiding Rows Using Ribbon Button

Unhide rows by using the Ribbon button available at the top of the Excel sheet.

Step 1: Click the Format button in the Cells group under the Home tab.

Step 2: Choose Unhide Rows from the Hide & Unhide menu under Visibility.

How to Unhide All Rows in Excel, Figure 3: Unhiding rows using the ribbon Unhiding rows using the ribbon

3.2 Unhiding Rows Using the Right-Click Menu

Unhide rows using an option from the context menu by right-clicking the chosen rows and choosing "Unhide".

How to Unhide All Rows in Excel, Figure 4: Unhide rows Unhide rows

3.3 Unhiding Using a Keyboard Shortcut

Keyboard shortcuts can also be used to unhide all hidden rows in an Excel document by pressing Ctrl + Shift + 9, which helps to make hidden rows visible again in the spreadsheet.

4.0 Hiding Rows Using IronXL

Microsoft Excel documents can be read and edited in C# using the IronXL .NET Framework. The standalone .NET software library for Excel can read a variety of spreadsheet formats, and there is no need to install Microsoft Excel or Interop.

The user-friendly C# API IronXL makes it easy to read, modify, and generate Excel spreadsheet files in the .NET environment. IronXL provides full support for .NET Core, .NET Framework, Xamarin, Mobile, Linux, macOS, and Azure. One of the best Excel spreadsheet libraries for C# is IronXL, which is part of the .NET Framework and .NET Core.

4.1 IronXL Features

  • It is possible to edit, read, and load data from XLS, XLSX, CSV, and TSV.
  • Data export and storage in the formats CSV, TSV, JSON, XLS, and XLSX.
  • Ranges are simple to use. Syntax for WorkSheet["A1:B10"]. Ranges can logically be combined.
  • Columns, rows, and ranges can all be sorted.
  • Cell styles, such as font, size, border, alignment, lock, freeze cells, hide/unhide rows, and number formats.

4.2 Hiding Rows in IronXL

IronXL can be used to hide row numbers in Excel with just a few lines of code. The below code is an example to hide a row in Excel.

using IronXL;

// Load an existing Excel workbook
WorkBook wb = WorkBook.LoadExcel("sample1.xlsx");

// Select the worksheet
WorkSheet ws = wb.GetWorkSheet("Sheet1");

// Hide the second row
ws.GetRow(1).Hidden = true;

// Save changes to the Excel file
wb.SaveAs("sample1.xlsx");
using IronXL;

// Load an existing Excel workbook
WorkBook wb = WorkBook.LoadExcel("sample1.xlsx");

// Select the worksheet
WorkSheet ws = wb.GetWorkSheet("Sheet1");

// Hide the second row
ws.GetRow(1).Hidden = true;

// Save changes to the Excel file
wb.SaveAs("sample1.xlsx");
Imports IronXL

' Load an existing Excel workbook
Private wb As WorkBook = WorkBook.LoadExcel("sample1.xlsx")

' Select the worksheet
Private ws As WorkSheet = wb.GetWorkSheet("Sheet1")

' Hide the second row
ws.GetRow(1).Hidden = True

' Save changes to the Excel file
wb.SaveAs("sample1.xlsx")
$vbLabelText   $csharpLabel

The example above loads an existing Excel document using the WorkBook.LoadExcel method by providing the path and file name. Once the Excel document is loaded in the WorkBook object, a specific Excel worksheet can be specified using the WorkBook method GetWorkSheet and pass the sheet name as a parameter. This creates a WorkSheet object, which provides functionality for the entire worksheet.

After getting the WorkSheet object, it is possible to select a row using the method GetRow by passing the row index as a parameter. This allows us to use the boolean value from the Hidden property and set it to true, which can hide and unhide rows in an Excel document. The above code is an example that hides the second row of the Excel document.

4.3 Unhiding Rows in IronXL

The following code can unhide multiple rows in Excel:

using IronXL;

// Load an existing Excel workbook
WorkBook wb = WorkBook.LoadExcel("sample1.xlsx");

// Select the worksheet
WorkSheet ws = wb.GetWorkSheet("Sheet1");

// Unhide the second row
ws.GetRow(1).Hidden = false;

// Save changes to the Excel file
wb.SaveAs("sample1.xlsx");
using IronXL;

// Load an existing Excel workbook
WorkBook wb = WorkBook.LoadExcel("sample1.xlsx");

// Select the worksheet
WorkSheet ws = wb.GetWorkSheet("Sheet1");

// Unhide the second row
ws.GetRow(1).Hidden = false;

// Save changes to the Excel file
wb.SaveAs("sample1.xlsx");
Imports IronXL

' Load an existing Excel workbook
Private wb As WorkBook = WorkBook.LoadExcel("sample1.xlsx")

' Select the worksheet
Private ws As WorkSheet = wb.GetWorkSheet("Sheet1")

' Unhide the second row
ws.GetRow(1).Hidden = False

' Save changes to the Excel file
wb.SaveAs("sample1.xlsx")
$vbLabelText   $csharpLabel

To unhide specific rows, follow the aforementioned steps and modify the instructions by selecting the row through the method GetRow, either by passing the row index as a parameter or by specifying the row. Then set the boolean value of Hidden to false.

Conclusion

The IronXL library is a development tool that provides all the advanced features required for a complex Excel application. It has an excellent feature that offers both developers and users a free trial, making it easy to evaluate its effectiveness. IronXL is one of the fastest libraries available, and developers can easily learn how to create an Excel document with just a few lines of code. With the library's assistance, it is possible to perform a wide range of Excel functions. To learn more about IronXL, please visit the tutorial page for more examples or refer to this example on how to read an Excel file.

常见问题解答

如何使用界面取消隐藏 Excel 中的所有行?

您可以使用功能区按钮取消隐藏 Excel 中的所有行。单击主页选项卡下“单元格”组中的“格式”按钮,然后从“显示/隐藏”菜单中选择“取消隐藏行”。或者,您可以使用键盘快捷键Ctrl + Shift + 9快速取消隐藏行。

如何以编程方式取消隐藏 Excel 中的行?

要以编程方式取消隐藏行,您可以使用 IronXL。使用WorkBook.LoadExcel加载您的 Excel 工作簿,使用GetWorkSheet选择工作表,并使用GetRow将所需行的 Hidden 属性设置为false

如何以编程方式隐藏 Excel 中的行?

使用 IronXL,您可以通过使用WorkBook.LoadExcel加载您的 Excel 工作簿、使用GetWorkSheet选择工作表并使用GetRow将行的 Hidden 属性设置为true来隐藏行。

使用 IronXL 进行 Excel 操作的好处是什么?

IronXL 允许您读取、编辑和生成 Excel 电子表格文件,而无需安装 Microsoft Excel。它支持 XLS、XLSX、CSV 和 TSV 等多种格式,并提供用户友好的 C# API 用于处理 Excel 任务,例如隐藏和取消隐藏行。

在 Excel 中取消隐藏行的重要性是什么?

在 Excel 中取消隐藏行对于数据可访问性和生产力至关重要。它有助于有效管理大型文档并确保所有数据保持可见,以便进行分析和决策。

我可以在不使用 Excel 的情况下自动化 Excel 行操作吗?

是的,您可以使用 IronXL 自动化 Excel 行操作。这是一个 .NET 库,您无需安装 Microsoft Excel。它提供了以编程方式隐藏和取消隐藏行的功能,可以集成到自定义应用程序中。

IronXL 如何增强电子表格管理中的生产力?

IronXL 通过允许开发人员以编程方式执行各种 Excel 功能,例如读取、编辑和导出数据,提高了生产力。这减少了对手动 Excel 操作的需求并简化了工作流程。

Curtis Chau
技术作家

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

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