C++操作docx文档----高价求助
有没有什么简单点的方法可以简单操作一下docx文档啊,就像操作txt文档那样,把数据输入就好。求求各位大佬帮帮。 #include <windows.h>
#include <combaseapi.h>
#include <iostream>
#import "C:\\Program Files\\Microsoft Office\\root\\Office16\\MSWORD.OLB" auto_search, auto_rename
Word::WdColor rgb(unsigned char r, unsigned char g, unsigned char b) {
return (Word::WdColor)((b << 16) | (g << 8) | r);
}
int main() {
CoInitialize(NULL);
Word::_ApplicationPtr Application(__uuidof(Word::Application));
Application->Visible = true;
Word::DocumentsPtr docs = Application->Documents;
Word::_DocumentPtr doc = docs->Add();
Word::RangePtr range = doc->Content;
range->Text = "hello world!";
Word::_FontPtr font(__uuidof(Word::Font));
font->Color = Word::wdColorRose;
font->Name = "Courier New";
font->Bold = true;
font->Size = 24;
range->Font = font;
range->Paragraphs->Alignment = Word::wdAlignParagraphCenter;
#if 0
range->Font->Color = rgb(255, 0, 0);
range->Font->Color = rgb(0, 255, 0);
range->Font->Color = rgb(0, 0, 255);
range->Font->Color = rgb(255, 192, 203);
range->Font->Color = rgb(218, 112, 214);
range->Font->Color = rgb(123, 104, 238);
#endif
std::cin.get();
Application->Quit(&variant_t(Word::wdDoNotSaveChanges));
CoUninitialize();
return 0;
}
c操作这玩意还是比较弱的,还是寻求高能脚本诸如python一类 c++吗?
推荐一个第三方的lib库吧,操作docx:https://github.com/DocxFactory/DocxFactory {:10_256:} 离谱 插眼,我也挺想知道的 人造人 发表于 2022-6-6 13:56
大佬可以请您详细讲一下吗?
#include <windows.h>
#include <combaseapi.h>
这两个头文件没用过{:10_266:} 烂泥化刚 发表于 2022-6-8 16:54
大佬可以请您详细讲一下吗?
#include
#include
先学这个
https://fishc.com.cn/forum-255-1.html
人造人 发表于 2022-6-9 00:55
先学这个
https://fishc.com.cn/forum-255-1.html
请问是windows编程吗
前一秒
刚刚开始看{:10_282:} 人造人 发表于 2022-6-9 00:55
先学这个
https://fishc.com.cn/forum-255-1.html
然后想请问您
<combaseapi.h>
这个库是作甚么的 烂泥化刚 发表于 2022-6-9 02:43
然后想请问您
这个库是作甚么的
https://docs.microsoft.com/en-us/windows/win32/api/combaseapi/ 理想小青年 发表于 2022-6-2 11:42
c++吗?
推荐一个第三方的lib库吧,操作docx:https://github.com/DocxFactory/DocxFactory
有没有啥操作手册之类的啊,求求 人造人 发表于 2022-6-6 13:56
这个应该是靠电脑安装了office提供了相应的函数接口,有没有可以移植的方法啊,最后生成的exe能移植到其他电脑上运行的那种 贾政景 发表于 2022-6-9 22:08
这个应该是靠电脑安装了office提供了相应的函数接口,有没有可以移植的方法啊,最后生成的exe能移植到其 ...
我没有找到这样的方法
书生丿意气 发表于 2022-6-6 22:16
离谱
用python还是其他什么的滚开这个帖子,老子问的C++ 烂泥化刚 发表于 2022-6-8 16:54
大佬可以请您详细讲一下吗?
#include
#include
windows.h是用来与windows系统交互
system函数是最常用的
可以涵盖大部分dos指令 贾政景 发表于 2022-6-9 22:08
这个应该是靠电脑安装了office提供了相应的函数接口,有没有可以移植的方法啊,最后生成的exe能移植到其 ...
那要看 那台电脑有没有和编写程序的电脑 版本相同的office吧
因为有些东西不是自己写的,所以局限性也挺大的
页:
[1]