Count number of cells in the Worksheet with C++
Contents
[
Hide
]
You may count the number of cells in the worksheet by using the Cells.GetCount() or Cells.GetCountLarge() properties as shown in the code example given below.
#include <iostream>
#include "Aspose.Cells.h"
using namespace Aspose::Cells;
int main()
{
Aspose::Cells::Startup();
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C
// Source directory path
U16String sourceDir(u"..\\Data\\01_SourceDirectory\\");
// Load source Excel file
Workbook workbook(sourceDir + u"BookWithSomeData.xlsx");
// Access first worksheet
Worksheet worksheet = workbook.GetWorksheets().Get(0);
// Print number of cells in the Worksheet
std::cout << "Number of Cells: " << worksheet.GetCells().GetCount() << std::endl;
// In case the number of cells is greater than 2147483647, use CountLarge
std::cout << "Number of Cells (CountLarge): " << worksheet.GetCells().GetCountLarge() << std::endl;
Aspose::Cells::Cleanup();
return 0;
}