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
| Requirement | Detail |
|---|---|
| C++ Compiler | C++17-compatible compiler (GCC 9+, Clang 10+, or MSVC 2019+) |
| CMake | Version 3.15 or higher |
| Git | Any recent version |
| Operating System | Linux, 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-CppStep 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_FOSSnamespace to avoid symbol clashes with other libraries. - The include entry point for most operations is
aspose/cells_foss/Workbook.h; include additional headers such asWorksheet.handCell.has needed. - Use CMake 3.15 or later; older versions may not support the bundled target configuration.
- For production builds, pass
-DCMAKE_BUILD_TYPE=Releasetocmaketo 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
| Issue | Cause | Fix |
|---|---|---|
fatal error: aspose/cells_foss/Workbook.h: No such file or directory | Include path not configured | Ensure target_include_directories points to the library’s include/ folder |
undefined reference to Aspose::Cells_FOSS::Workbook::Workbook() | Library not linked | Add target_link_libraries(MyApp Aspose.Cells.Foss.Cpp) in CMakeLists.txt |
| CMake version error | CMake < 3.15 | Upgrade CMake to 3.15+ or adjust the cmake_minimum_required version |
| Build fails on C++14 mode | Standard too old | Add set(CMAKE_CXX_STANDARD 17) before the add_executable call |
Next Steps
- License — Review the MIT license terms for Aspose.Cells FOSS for C++.
- Features — Browse all supported spreadsheet capabilities.
- Working with Spreadsheet Management — Learn workbook and worksheet operations.