Installation

Installation

This guide shows how to set up Aspose.Cells FOSS for C++ on your development machine, build the library, and verify the setup with a minimal spreadsheet-creation program.


Prerequisites

RequirementDetail
C++ CompilerC++17-compatible compiler (GCC 9+, Clang 10+, or MSVC 2019+)
CMakeVersion 3.15 or higher
GitAny recent version
Operating SystemLinux, macOS, or Windows

Step 1 — Clone the Repository

Clone the Aspose.Cells FOSS for C++ source repository:

git clone https://github.com/aspose-cells-foss/Aspose.Cells-FOSS-for-Cpp.git
cd Aspose.Cells-FOSS-for-Cpp

Step 2 — Build the Samples

Use the bundled CMake configuration to build the samples project, which also compiles the library:

cd samples
mkdir build
cd build
cmake ..
cmake --build .

The build output places the compiled binaries in the build/ directory.


Step 3 — Include the Library in Your Project

Add the library headers and source tree to your own CMakeLists.txt via FetchContent or a local path include:

cmake_minimum_required(VERSION 3.15)
project(MyProject CXX)

set(CMAKE_CXX_STANDARD 17)

# Option A: local path
add_subdirectory(path/to/Aspose.Cells-FOSS-for-Cpp)

add_executable(MyApp main.cpp)
target_link_libraries(MyApp PRIVATE Aspose.Cells.Foss.Cpp)

Step 4 — Verify the Installation

Create a minimal main.cpp that creates and saves an XLSX file:

#include "aspose/cells_foss/Workbook.h"
#include "aspose/cells_foss/WorksheetCollection.h"
#include "aspose/cells_foss/Worksheet.h"
#include "aspose/cells_foss/Cell.h"

using namespace Aspose::Cells_FOSS;

int main() {
    Workbook workbook;
    Worksheet& sheet = workbook.GetWorksheets()[0];
    sheet.SetName("Hello");
    sheet.GetCells()["A1"].PutValue("Hello, Aspose.Cells FOSS!");
    workbook.Save("hello.xlsx");
    return 0;
}

Build and run. If hello.xlsx is created in the working directory, the installation is successful.


Tips and Best Practices

  • Always use the Aspose::Cells_FOSS namespace to avoid symbol clashes with other libraries.
  • The include entry point for most operations is aspose/cells_foss/Workbook.h; include additional headers such as Worksheet.h and Cell.h as needed.
  • Use CMake 3.15 or later; older versions may not support the bundled target configuration.
  • For production builds, pass -DCMAKE_BUILD_TYPE=Release to cmake to enable optimizations.
  • Keep the clone directory as your library root; do not copy individual headers — relative include paths in the library headers depend on the original directory layout.

Common Issues

IssueCauseFix
fatal error: aspose/cells_foss/Workbook.h: No such file or directoryInclude path not configuredEnsure target_include_directories points to the library’s include/ folder
undefined reference to Aspose::Cells_FOSS::Workbook::Workbook()Library not linkedAdd target_link_libraries(MyApp Aspose.Cells.Foss.Cpp) in CMakeLists.txt
CMake version errorCMake < 3.15Upgrade CMake to 3.15+ or adjust the cmake_minimum_required version
Build fails on C++14 modeStandard too oldAdd set(CMAKE_CXX_STANDARD 17) before the add_executable call

Next Steps

See Also