Features
Features
Aspose.Cells FOSS for C++ is an open-source C++ library for creating, loading, editing, and saving Excel .xlsx workbooks without requiring Microsoft Excel. The library exposes a header-only C++ API organized around a small set of core classes.
Workbook and Worksheet Management
The Workbook class is the root object for all spreadsheet operations. Use it to create a new workbook, load an existing XLSX file, or save changes to disk.
- Create a new workbook with
Workbook() - Load an XLSX file with
Workbook(filePath) - Save to file with
Workbook::Save(fileName) - Access all sheets via
Workbook::GetWorksheets() - Add, rename, and configure sheets through the
Worksheetclass
Cell Values and Formulas
The Cell class represents a single spreadsheet cell. It supports reading and writing text, numeric, boolean, and formula values.
- Write values with
Cell::PutValue(value)andCell::SetValue(value) - Read values with
Cell::GetValue()returning aCellValue - Set formulas with
Cell::SetFormula(formula)— standard Excel formula syntax - Address cells by name (
"A1") or row/column index viaCells::operator[](cellName)
Cell Styling
Apply rich formatting to cells using the Style class. Obtain the current style from Cell::GetStyle(), modify it, and apply it back with Cell::SetStyle(style).
- Font configuration via
Style::Font()returning aFontobject — bold, color, size - Background fill patterns via
Style::SetPattern(FillPattern)andStyle::SetForegroundColor(Color) - Border configuration via
Style::Borders() - Number format strings via
Style::SetNumberFormat(format)
Page Setup and Print Layout
The PageSetup class enables configuring worksheet print settings such as paper size, orientation, margins, scaling, and header/footer text.
- Set paper size with
PageSetup::SetPaperSize(PaperSizeType) - Set print orientation with
PageSetup::SetOrientation(PageOrientationType) - Configure margins:
PageSetup::SetTopMargin,SetBottomMargin,SetLeftMargin,SetRightMargin - Fit-to-page scaling with
PageSetup::SetFitToPagesTallandSetFitToPagesWide
Conditional Formatting
The ConditionalFormattingCollection class manages rule-based cell formatting. Rules can be added to worksheet ranges and priority can be managed automatically.
- Add rules with
ConditionalFormattingCollection::Add() - Remove rules by index or area
- Retrieve next available priority with
ConditionalFormattingCollection::GetNextPriority()
Auto-Filter
The AutoFilter class supports applying column-level data filters to worksheet ranges.
- Set the filter range with
AutoFilter::SetRange(rangeAddress) - Clear all active filters with
AutoFilter::Clear() - Manage custom filters via
AutoFilterCustomFilterandAutoFilterCustomFilterCollection
Named Ranges and Defined Names
The DefinedName class stores workbook-level or sheet-level named formulas and ranges for reuse in formulas and code.
- Get the defined name with
DefinedName::GetName() - Get or set the formula (range address) with
DefinedName::GetFormula()/SetFormula(formula) - Scope to a specific sheet using
DefinedName::GetLocalSheetIndex()
XLSX Format Support
| Format | Load | Save |
|---|---|---|
| XLSX | ✔ | ✔ |
| CSV | ✔ | — |
All load and save operations use the Workbook::Save(fileName) overloads. The format is inferred from the file extension by default.
API Reference Summary
| Class | Description |
|---|---|
Workbook | Root spreadsheet object — create, load, and save XLSX files |
Worksheet | Single worksheet — name, cells, page setup, and auto-filter |
Cell | Single cell — value, formula, and style operations |
Style | Cell style facade — font, fill, borders, and number format |
Font | Font settings — bold, color, size |
PageSetup | Print layout — paper size, orientation, margins, scaling |
ConditionalFormattingCollection | Collection of conditional formatting rules |
AutoFilter | Column-level auto-filter for a worksheet range |
DefinedName | Named range or formula definition |