# minidocx
**Repository Path**: totravel/minidocx
## Basic Information
- **Project Name**: minidocx
- **Description**: 用于创建 Microsoft Word 文档的 C++ 类库,支持插入表格、图片、列表,支持修改页面格式、段落格式、字体格式和表格格式,支持新建段落样式、字体样式。
- **Primary Language**: C++
- **License**: MIT
- **Default Branch**: next
- **Homepage**: https://github.com/totravel/minidocx
- **GVP Project**: No
## Statistics
- **Stars**: 99
- **Forks**: 22
- **Created**: 2022-06-28
- **Last Updated**: 2026-02-06
## Categories & Tags
**Categories**: utils
**Tags**: docx, Word, ooxml, Office
## README
English | [简体中文](./README-zh_CN.md)
minidocx
C++ library for manipulating Microsoft Word Document
## About
minidocx is a modern, free, open-source, cross-platform, light-weight, and user-friendly C++20 library for manipulating Microsoft Word Document (.docx file) as described in [ECMA 376 5th edition](https://www.ecma-international.org/publications-and-standards/standards/ecma-376) or [ISO/IEC 29500-1:2016](https://www.iso.org/standard/71691.html) without installing MS Office or WPS Office.
> [!WARNING]
> minidocx 1.0 is currently in beta and should not be used in production.
> [!NOTE]
> Check out the master branch to view minidocx 0.6.
## Features
- Section
- Paragraph
- Rich text
- Table
- Picture
- Style
- List
## Preview
Light Mode | Dark Mode
---------- | ---------
 | 
## Example
Here's an example of how to use minidocx to create a .docx file.
```cpp
#include "minidocx/minidocx.hpp"
#include
int main()
{
using namespace md;
try {
Document doc;
SectionPointer sect = doc.addSection();
ParagraphPointer para = sect->addParagraph();
para->prop_.align_ = Alignment::Centered;
RichTextPointer rich = para->addRichText("Happy Chinese New Year!");
rich->prop_.fontSize_ = 32;
rich->prop_.color_ = "FF0000";
doc.saveAs("a.docx");
}
catch (const Exception& ex) {
std::cerr << ex.what() << std::endl;
}
return 0;
}
```
## Building
To build minidocx lib you'll need a C++20 compiler and CMake 3.28.
```bash
git clone git@github.com:totravel/minidocx.git
cd minidocx
# Windows
cmake --preset x64-win-msbuild-v143
cmake --build --preset x64-win-msbuild-v143-debug
./out/x64-win-msbuild-v143/bin/exe/Debug/myapp.exe
# Linux
cmake --preset x64-linux-ninja-gcc
cmake --build --preset x64-linux-ninja-gcc-debug
./out/x64-linux-ninja-gcc/bin/exe/myapp
```
A static library is built by default. If you want to use a shared build of minidocx, set the `BUILD_SHARED` CMake option to `true`.
## Documentation
- [User Guide](./guide.md)
## Donation
If you benefit from this project, please consider donating to help me sustain my projects actively and make more of my ideas come true.
Alipay | WeChat Pay
------ | ----------
 | 
## Sponsor
You can sponsor this library at [AFDIAN](https://afdian.com/a/totravel).
Your sponsorship means a lot to me. It will help me sustain my projects actively and make more of my ideas come true. Much appreciated! 💖 🙏
## License
minidocx is released to the public for free under the terms of the MIT License. See [LICENSE](./LICENSE) for the full text of the license. [LICENSE](./LICENSE) should be distributed alongside any assemblies that use minidocx in source or compiled form.