totravel / minidocx Goto Github PK
View Code? Open in Web Editor NEWC++ library for creating Microsoft Word Document (.docx). 用于创建 Microsoft Word 文档的 C++ 类库
License: MIT License
C++ library for creating Microsoft Word Document (.docx). 用于创建 Microsoft Word 文档的 C++ 类库
License: MIT License
@totravel,
Is there conversion library function? Maybe it's about WinAPI, but I'm not sure. The situation is this: user can specify (.doc, .docx) files, parser is only .docx
Hi, I'm writing bindings of minidocx for the Nim programming language and got an error in minidocx.cpp
since it couldn't find std::find
, and it seems I needed to #include <algorithm>
.
I'm not sure if this is an actual error of minidocx or if it has something to do with my computer.
想法不错,期待这个minidocx。
测试用例里面生成的docx文件,mac os 自带的pages打开没有问题,但是LibreOffice打开失败
希望有可能表格和图片功能
Example:
bool Document::Open(const std::string& path, bool createIfNotExist = false)
docx::Document doc;
doc->Open(path, true);
or C file functions be like
doc->Open(path, 'r');
doc->Open(path, 'w');
doc->Open(path, 'w+');
doc->Open(path, 'a');
doc->Open(path, 'rb');
@totravel,
I don't see such method, is there a way to do it?
@totravel, hi again.
more info about feature openxml: https://learn.microsoft.com/en-us/dotnet/api/documentformat.openxml.wordprocessing.documentvariables?view=openxml-3.0.1
or example COM/OLE procedure: SetDocumentVar
and GetDocumentVar
in WordServer
@totravel, how to insert and read in OOXML by formula
Example:
word - https://stackoverflow.com/questions/25709775/reading-equations-formula-from-word-docx
excel - https://stackoverflow.com/questions/6309109/using-open-xml-how-do-you-insert-a-formula-into-an-excel-2010-worksheet
请问什么时候支持表格、图片等内容的写入呢
@totravel,
it may be worth adding separate SetPath(const std::string& path)
method that only sets path from parameter function. Because in my code I made in class private member docx::Document*
. I have constructor class working on creating an object document, but there is no way to reassigning path.
输入 tab 是用来对齐用的,代码如下:
auto p = doc.AppendParagraph("甲 方:\t\t\t\t乙 方:", 12, "Times New Roman", "宋体");
以上的 \t 并不起作用,生成的文件中被替换成了空格,请教应如何输入 tab 控制符
MergeCells 可以合并列,无法合并行
@totravel, many thanks and hello again.
How to find Word objects and return their, to then insert/replace before/after it and edit object properties.
Example:
auto text = GetWordTextItem("TEXT FOR SEARCH");
text.SetText("NEW VALUE");
or
GetWordTextItem(string or formula or id element or xml node)
Example:
for (pugi::xml_node i = impl_->w_body_.first_child(); i; i = i.next_sibling()) {
if (std::strcmp(i.name(), "w:p") != 0) continue;
for (pugi::xml_node j = i.first_child(); j; j = j.next_sibling()) {
if (std::strcmp(j.name(), "w:r") == 0) {
for (pugi::xml_node k = j.first_child(); k; k = k.next_sibling()) {
if (std::strcmp(k.name(), "w:t") == 0) {
k.value = "new value";
}
}
}
}
使用 AppendParagraph 或 AppendRun 函数向文本中添加的 '\n' 换行无法添加到 Word 文档中,只能调用 AppendLineBreak 函数手动添加换行。
AppendParagraph 和 AppendRun 函数能够将字符串中的 '\n' 换行添加到 Word 文档中。
#include "minidocx.hpp"
using namespace docx;
int main()
{
Document doc("Test.docx");
auto p = doc.AppendParagraph("This is first line. \n This is second line.", 16);
doc.Save();
return 0;
}
@totravel, great day. How to add bookmark in Word file and go to exist bookmark object?
@totravel, it would be really convenient to work with bookmarks if there were these functions.
/**
* Compare bookmarks.
* @param name1 Name first bookmark.
* @param name2 Name second bookmark.
* @return enum
* 0 Bookmarks match.
* 1 The first bookmark is located below the second one and does not intersect it.
* 2 The first tab is above the second one and does not intersect it.
* 3 The first bookmark is located below the second one and crosses it.
* 4 The first tab is above the second one and crosses it.
* 5 The first bookmark includes the second one.
* 6 The second bookmark includes the first one.
* 7 Bookmarks start in one place, but the first one is longer.
* 8 Bookmarks start in one place, but the second one is longer.
* 9 Bookmarks end in one place, but the first one is longer.
* 10 Bookmarks end in one place, but the second one is longer.
* 11 Bookmarks are next to each other and the first one is below the second one.
* 12 Bookmarks are located next to each other and the first one is higher than the second one.
* 13 One of the bookmarks does not exist.
*/
int CmpBookmarks(std::string name1, std::string name2);
/**
* Checking the existence of a bookmark.
* @param name Name bookmark.
* @return bool true if bookmark exists, false otherwise.
*/
bool ExistingBookmark(std::string name);
I hope to implement the functionality of generating multi-level headings and a table of contents based on the code of minidocx.cpp, but I'm not sure where to start;
Also, are the contents such as DOCUMENT_XML in the macro definition fixed, or do they need to be changed according to the document?
Thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.