From 664b0dab080993651d7dcf984940ae7d3d3f05d4 Mon Sep 17 00:00:00 2001 From: santiprajaSF4793 Date: Wed, 28 Jan 2026 21:51:59 +0530 Subject: [PATCH 1/2] 994785-WorksheetEmptyUG-HF --- Document-Processing-toc.html | 3 + ...-check-if-a-worksheet-is-empty-in-excel.md | 73 +++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 Document-Processing/Excel/Excel-Library/NET/faqs/how-to-check-if-a-worksheet-is-empty-in-excel.md diff --git a/Document-Processing-toc.html b/Document-Processing-toc.html index a1e86d792..95d7105f0 100644 --- a/Document-Processing-toc.html +++ b/Document-Processing-toc.html @@ -6299,6 +6299,9 @@
  • How to retrieve the name of the chart in an Excel worksheet?
  • +
  • + How to check if a worksheet is empty in Excel? +
  • diff --git a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-check-if-a-worksheet-is-empty-in-excel.md b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-check-if-a-worksheet-is-empty-in-excel.md new file mode 100644 index 000000000..f2b406211 --- /dev/null +++ b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-check-if-a-worksheet-is-empty-in-excel.md @@ -0,0 +1,73 @@ +--- +title: Check if a worksheet is empty in Excel | Syncfusion +description: Code example to check if a worksheet is empty in Excel using Syncfusion .NET Excel library (XlsIO). +platform: document-processing +control: XlsIO +documentation: UG +--- + +# How to check if a worksheet is empty in Excel? + +The following code examples demonstrate checking if a worksheet is empty in Excel using C# (Cross-platform and Windows-specific) and VB.NET. + +{% tabs %} +{% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/XlsIO-Examples/master/FAQ/Worksheet/.NET/CheckIfWorksheetIsEmpty/CheckIfWorksheetIsEmpty/Program.cs,180" %} +using (ExcelEngine excelEngine = new ExcelEngine()) +{ + IApplication application = excelEngine.Excel; + application.DefaultVersion = ExcelVersion.Xlsx; + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/Input.xlsx")); + IWorksheet worksheet; + for (int i = 0; i < workbook.Worksheets.Count; i++) + { + // Access the worksheet + worksheet = workbook.Worksheets[i]; + + // Check if worksheet is empty + if (worksheet.UsedCells.Length == 0) + Console.WriteLine("The worksheet with name \""+ worksheet.Name + "\" is empty"); + } +} +{% endhighlight %} + +{% highlight c# tabtitle="C# [Windows-specific]" %} +using (ExcelEngine excelEngine = new ExcelEngine()) +{ + IApplication application = excelEngine.Excel; + application.DefaultVersion = ExcelVersion.Xlsx; + IWorkbook workbook = application.Workbooks.Open("Input.xlsx"); + IWorksheet worksheet; + for (int i = 0; i < workbook.Worksheets.Count; i++) + { + // Access the worksheet + worksheet = workbook.Worksheets[i]; + + // Check if worksheet is empty + if (worksheet.UsedCells.Length == 0) + Console.WriteLine("The worksheet with name \""+ worksheet.Name + "\" is empty"); + } +} +{% endhighlight %} + +{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Using excelEngine As New ExcelEngine() + Dim application As IApplication = excelEngine.Excel + application.DefaultVersion = ExcelVersion.Xlsx + + Dim workbook As IWorkbook = application.Workbooks.Open("Input.xlsx") + Dim worksheet As IWorksheet + + For i As Integer = 0 To workbook.Worksheets.Count - 1 + ' Access the worksheet + worksheet = workbook.Worksheets(i) + + ' Check if worksheet is empty + If worksheet.UsedCells.Length = 0 Then + Console.WriteLine("The worksheet with name """ & worksheet.Name & """ is empty") + End If + Next +End Using +{% endhighlight %} +{% endtabs %} + +A complete working example in C# is present on this GitHub page. \ No newline at end of file From 2b136720b355e9a6cbfc409d1a30b8acde4479a7 Mon Sep 17 00:00:00 2001 From: santiprajaSF4793 Date: Wed, 28 Jan 2026 22:02:26 +0530 Subject: [PATCH 2/2] 994785-WorksheetEmptyUG-HF --- .../NET/faqs/how-to-check-if-a-worksheet-is-empty-in-excel.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-check-if-a-worksheet-is-empty-in-excel.md b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-check-if-a-worksheet-is-empty-in-excel.md index f2b406211..5384e65b0 100644 --- a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-check-if-a-worksheet-is-empty-in-excel.md +++ b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-check-if-a-worksheet-is-empty-in-excel.md @@ -8,7 +8,7 @@ documentation: UG # How to check if a worksheet is empty in Excel? -The following code examples demonstrate checking if a worksheet is empty in Excel using C# (Cross-platform and Windows-specific) and VB.NET. +The following code examples demonstrate how to check whether a worksheet is empty in Excel using C# (Cross-platform and Windows-specific) and VB.NET. {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/XlsIO-Examples/master/FAQ/Worksheet/.NET/CheckIfWorksheetIsEmpty/CheckIfWorksheetIsEmpty/Program.cs,180" %}