---
Product: Aspose.Cells
Platform: cpp
Page Type: docs
Canonical URL: https://docs.aspose.org/cells/cpp/developer-guide/working-with-xlsx-packaging
---

# Working with XLSX Packaging

Understand how Aspose.Cells FOSS for C++ reads and writes the XLSX Open XML format, covering the serializer, document properties, styles, and workbook parts.

## Overview

Aspose.Cells FOSS for C++ reads and writes the `.xlsx` Open XML format through a dedicated serialization layer. The `XlsxWorkbookSerializer` class orchestrates loading and saving of all workbook parts including worksheets, styles, defined names, document properties, and auto-filters.

---

### Loading and Saving XLSX Files

Use the `Workbook` class for all load and save operations. Internally, `XlsxWorkbookSerializer` handles the Open XML packaging:

```cpp
#include "aspose/cells_foss/Workbook.h"

using namespace Aspose::Cells_FOSS;

int main() {
    // Load existing XLSX
    Workbook workbook("input.xlsx");

    // Modify content...

    // Save back to XLSX
    workbook.Save("output.xlsx");
    return 0;
}
```

---

### Document Properties

XLSX files carry core and extended document properties (title, author, creation date). These are managed by `XlsxDocumentProperties`, which builds and loads the `docProps/core.xml` and `docProps/app.xml` parts:

| Part | Managed by | Contains |
|---|---|---|
| `docProps/core.xml` | `XlsxDocumentProperties::BuildCorePropertiesDocument` | Title, author, created, modified |
| `docProps/app.xml` | `XlsxDocumentProperties::BuildExtendedPropertiesDocument` | Application name, version |

---

### Workbook Metadata and Settings

Workbook-level metadata — calculation settings, book views, and workbook protection — is managed by `XlsxWorkbookProperties`:

- `BuildWorkbookPropertiesElement` — writes workbook calculation and iteration settings
- `BuildWorkbookProtectionElement` — writes workbook-level password protection
- `BuildBookViewsElement` — writes window position and active sheet settings

---

### Styles and Number Formats

The styles part (`xl/styles.xml`) is managed by `XlsxWorkbookStyles`. It maps `Style` objects from the in-memory model to serialized font, fill, border, and number-format records:

- `BuildStylesheet` — serializes all styles to XML
- `LoadStylesheet` — reads styles from an existing XLSX file
- `StylesEqual` — checks whether two style objects would produce identical XML

---

### Auto-Filter Packaging

Auto-filter state per worksheet is serialized by `XlsxWorkbookAutoFilter`:

- `BuildAutoFilterElement` — writes the `<autoFilter>` XML element
- `LoadAutoFilter` — reads auto-filter configuration from a worksheet part

---

### Defined Names

Named ranges and formulas are packaged in the workbook part and loaded by `XlsxWorkbookDefinedNames`:

- `BuildDefinedNames` — writes all `DefinedName` entries to the workbook XML
- `LoadWorkbookDefinedNames` — reads defined names during file load

---

### Tips and Best Practices

- Use `Workbook::Save(fileName)` as the single exit point — do not invoke serializer classes directly unless extending the library.
- The `.xlsx` format is the only fully supported format; saving to other formats is not available in v0.1.
- File paths passed to `Workbook(filePath)` or `Save(filePath)` must use the platform path separator and be fully qualified when running in environments where the working directory may vary.
- Workbook protection applied via `XlsxWorkbookProperties::BuildWorkbookProtectionElement` is independent of worksheet-level protection set through `Worksheet::Protect`.

---

### Common Issues

| Issue | Cause | Fix |
|---|---|---|
| File fails to load | Invalid or encrypted XLSX | Ensure the file is a plain (non-password-protected) XLSX |
| Styles lost after save | Style not applied before Save | Call `Cell::SetStyle(style)` before `Workbook::Save` |
| Defined names missing after round-trip | Scope set to wrong sheet | Use `DefinedName::SetFormula` with full range address |

---

### API Reference Summary

| Class/Method | Description |
|---|---|
| `Workbook(filePath)` | Load an XLSX file |
| `Workbook::Save(fileName)` | Save to XLSX |
| `XlsxWorkbookSerializer::Save` | Internal: serializes model to Open XML |
| `XlsxWorkbookSerializer::Load` | Internal: deserializes Open XML to model |
| `XlsxDocumentProperties` | Core and extended document property packaging |
| `XlsxWorkbookProperties` | Workbook metadata and settings serialization |
| `XlsxWorkbookStyles` | Style sheet packaging |
| `XlsxWorkbookAutoFilter` | Auto-filter XML packaging |
| `XlsxWorkbookDefinedNames` | Defined name XML packaging |

## See Also

- [Aspose.Cells for C++ — Enterprise Documentation](https://docs.aspose.com/cells/cpp/)