From 9df7c83ca6bc1df98921430695d15a9b56afdeae Mon Sep 17 00:00:00 2001 From: Emmanuel Pescosta Date: Wed, 15 Apr 2020 11:28:36 +0200 Subject: [PATCH] worksheet: Add method to check if the worksheet is empty A worksheet is considered empty if it doesn't have any cells. --- include/xlnt/worksheet/worksheet.hpp | 6 ++++++ source/worksheet/worksheet.cpp | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/include/xlnt/worksheet/worksheet.hpp b/include/xlnt/worksheet/worksheet.hpp index b8a879792..969ab0b90 100644 --- a/include/xlnt/worksheet/worksheet.hpp +++ b/include/xlnt/worksheet/worksheet.hpp @@ -770,6 +770,12 @@ class XLNT_API worksheet /// bool has_drawing() const; + /// + /// Returns true if this worksheet is empty. + /// A worksheet is considered empty if it doesn't have any cells. + /// + bool is_empty() const; + private: friend class cell; friend class const_range_iterator; diff --git a/source/worksheet/worksheet.cpp b/source/worksheet/worksheet.cpp index bb7141e2a..b9b6fc200 100644 --- a/source/worksheet/worksheet.cpp +++ b/source/worksheet/worksheet.cpp @@ -1335,4 +1335,9 @@ bool worksheet::has_drawing() const return d_->drawing_.is_set(); } +bool worksheet::is_empty() const +{ + return d_->cell_map_.empty(); +} + } // namespace xlnt