作者:mobiledu2502917123 | 来源:互联网 | 2022-12-17 14:02
BCB 6.0用OLE方式可以读写Excel 2007文档.xlsx吗?
第三方控件呢?
11 个解决方案
OLE 依赖 Office 的版本,和 C++Builder 的版本关系不大。
妖哥也玩通宵了
OleVariant WordFile(strPic+_T(".doc"));
WordApp->Connect();
OleVariant NewTemplate(false);
OleVariant Template;
OleVariant DocumentType(0);
OleVariant Visible(false);
//调用Add函数
WordApp->Documents->Add(Template,NewTemplate,DocumentType,Visible);
//连接到新建的文档
WordDocument->ConnectTo(WordApp->Documents->Item(Variant(1)));
BSTR FileName=strPic.w_str();
TImage* imagePdf = new TImage(this);
imagePdf->Picture->LoadFromFile(strPic);
WordApp->Selection->PageSetup->PageHeight =imagePdf->Picture->Height;
WordApp->Selection->PageSetup->PageWidth =imagePdf->Picture->Width;
imagePdf->Picture->Graphic = NULL;
delete imagePdf;
imagePdf=NULL;
OleVariant LinkToFile(false), SaveWithDocument(false);
WordDocument->InlineShapes->AddPicture(FileName);
OleVariant pdfFile(strPic+_T(".pic.pdf"));
OleVariant format(17);
WordDocument->SaveAs(pdfFile, format);
OleVariant changeClose(false);
WordDocument->Close(changeClose);
WordApp->Disconnect();