0
点赞
收藏
分享

微信扫一扫

c++ word 不依赖软件操作


1、Duck

可以提取word的内容与表格,新建工程直接复制源码就可以得到库

c++ word 不依赖软件操作_word

 

使用实例如下所示:

using namespace duckx;
duckx::Document doc("file.docx");
doc.open();

//获取当前word中所有的表格
for (auto p = doc.tables(); p.has_next(); p.next())
{
//获取所有行
for (auto r = p.rows(); r.has_next(); r.next())
{
//获取所有列的数据
for (auto r1 = r.cells(); r1.has_next(); r1.next())
{
for (auto r2 = r1.paragraphs(); r2.has_next(); r2.next())
{
for (auto r3 = r2.runs(); r3.has_next(); r3.next())
{
std::string strText = r3.get_text();
std::string str1 = UTF8ToGB2312(strText);
int yy = 55;
}
}
}
}
}
//读取当前word里面普通的内容
for (auto _doc = doc.paragraphs(); _doc.has_next(); _doc.next())
{
for (auto r = _doc.runs(); r.has_next(); r.next())
{
std::string strText = r.get_text();
std::string str1 = UTF8ToGB2312(strText);
int yy = 55;
}
}

2、DocxFactory 对于doc模板操作比较合适

可以下下载相关的头文件,lib库以及dll文件

c++ word 不依赖软件操作_新建工程_02

举报

相关推荐

0 条评论