DEV Community

Cover image for C++ has no Apache POI. So I wrote one.
Jakub Melka
Jakub Melka

Posted on

C++ has no Apache POI. So I wrote one.

If you need to read or write DOCX, XLSX and PPTX files from native C++, there is no good answer. .NET has Open-XML-SDK. Java has Apache POI. C++ has a few XLSX-only libraries - OpenXLSX, QXlsx, libxlsxwriter among them - and nothing feature-rich that covers all three formats.

I hit that wall last year on my own project. After searching long enough to be confident I was not simply missing something, I decided to write the library myself. It is called ExyokiOffice, it is MIT licensed, and it now covers Word, Excel and PowerPoint behind one API.

The part I care about most: nothing gets silently dropped

Open a document containing charts, SmartArt or a vendor extension with most open-source Office libraries, save it, and the honest question is: what did I just lose? Usually nothing tells you. The elements the library does not understand are simply gone, and you find out when someone opens the file.

I designed ExyokiOffice so that content preservation is a contract. Elements and attributes the library does not recognize are retained in the internal XML DOM and written back when the document is saved. Round-trip preservation is checked against a corpus of real documents, not only synthetic ones.

That is the difference between a library you can put in a production pipeline and one you can only safely use on documents you created yourself.

No managed runtime, no external dependencies

No .NET Framework. No Java Virtual Machine. The only dependency is the standard C++ library.

Given the scope I expected the result to be big, and I was surprised that it is not. The compressed packages, including a Docker image containing the CLI tool and the MCP servers, come in under 30 MB.

Two APIs, because you will need both

The high-level API is built for the common case and does not ask you to know the underlying specifications.

#include "ExyokiOffice/Word/WordDocument.hpp"

int main()
{
    using namespace ExyokiOffice::Word;

    auto editor = WordDocumentEditor::CreateNew();
    editor->AddHeading("Hello world");
    editor->AddParagraph("This document was created by ExyokiOffice.");
    editor->SaveToFile("Hello.docx");
}
Enter fullscreen mode Exit fullscreen mode

And here is a small Excel example:

#include "ExyokiOffice/Excel/ExcelDocument.hpp"

int main()
{
    using namespace ExyokiOffice::Excel;

    auto editor = ExcelDocumentEditor::CreateNew();
    auto sheet = editor->FirstWorksheet();
    sheet->SetCellText(1, 1, "Hello world");
    sheet->SetCellText(2, 1, "This workbook was created by ExyokiOffice.");
    editor->SaveToFile("Hello.xlsx");
}
Enter fullscreen mode Exit fullscreen mode

When the high-level API is not enough, you drop into a DOM-like low-level API similar to Open-XML-SDK and modify the tree directly. You do not have to choose between them up front.

What else is in it

  • exyoki, a CLI tool: validation, conversion, full-text search, redaction and statistics, without writing a line of code
  • Schema and semantic validation against a specific Office version
  • Format conversion, including DOCX to Markdown and back
  • A security model where access to external resources is denied by default
  • Machine-readable CLI output in JSON or XML, for scripts, automation and AI agents
  • MCP servers for each document type, one per format - experimental, and I would rather say so than imply otherwise
exyoki info corpus/word/The_United_States_of_America.docx
exyoki search corpus/word/Open_Source_Software.docx "license" --ignore-case
exyoki validate corpus/excel/Formulas.xlsx
exyoki stat corpus/powerpoint/Yellowstone.pptx
exyoki convert corpus/word/The_United_States_of_America.docx usa.md
Enter fullscreen mode Exit fullscreen mode

What it cannot do

No rendering, and no conversion to raster or SVG images. No legacy binary formats - DOC, XLS, PPT. The MCP servers are experimental and need real-world testing.

All the major parts of the library are finished and covered by unit tests. I am currently running coverage tooling to find the gaps and fix what it turns up.

If you work with Office documents in C++

This is a one-person project and I am at the start of a long road. If there is a feature you need and it is not there, open an issue. For a library like this, that is genuinely the most useful thing you can do.

GitHub logo JakubMelka / ExyokiOffice

A modern, MIT-licensed native C++ library for creation and modification of Open XML documents (DOCX, XLSX, PPTX), designed for cross-platform and dependency-free use.

ExyokiOffice

Smoke License: MIT C++20

ExyokiOffice logo

A native C++20 toolkit for creating and editing Word, Excel, and PowerPoint documents. Work with .docx, .xlsx, and .pptx through high-level editors or a typed OpenXML DOM, without Microsoft Office, .NET, Java, or Python at build time or runtime.

ExyokiOffice is designed for applications that need to generate or modify Office documents while retaining access to the underlying package. Content outside the high-level editing model is preserved instead of being silently dropped.

Quick start · Choose an API · Compatibility · Documentation · Comparison

Why ExyokiOffice

  • One native library for all three Office formats. Create and edit Word documents, Excel workbooks, and PowerPoint presentations from C++20.
  • Start high-level, go low-level when needed. Friendly editors cover common authoring tasks; the generated typed DOM and OPC packaging layer remain available for precise OpenXML work.
  • Preserve what you do not edit. The compatibility matrix distinguishes features the library can create…

Top comments (0)