本文主要是介绍C++ COM EXCEL插入PDF,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
C++ COM EXCEL插入PDF
MFC库的头文件生成方法请参考
https://www.cnblogs.com/nxopen2018/p/10981416.html
操作excel的其他方法参考以下连接
https://www.cnblogs.com/nxopen2018/p/11055161.html
var = (long)1;//获取到表一的标识符,序号从1开始
sheet.AttachDispatch(sheets.get_Item(var));
sheet.Activate();
CRange rgMyRge;
CString PDFpath;
PDFpath = filename.c_str();
//range.AttachDispatch(sheet.get_Cells(), TRUE);
//com插入PDF方法
rgMyRge = sheet.get_Range(_variant_t(L"G2"), _variant_t(L"I5"));
CShapes m_shapes = sheet.get_Shapes();
CShape m_shape;
COleVariant vTrue((short)TRUE), vFalse((short)FALSE), vOpt((long)DISP_E_PARAMNOTFOUND, VT_ERROR);m_shape = m_shapes.AddOLEObject(vOpt, COleVariant(PDFpath), vFalse, vFalse, vOpt, vFalse, vOpt, _variant_t(rgMyRge.get_Left()), _variant_t(rgMyRge.get_Top()), _variant_t(10), _variant_t(10));m_shape.put_Placement(3);
//确定嵌入PDF图像的位置
m_shape.ReleaseDispatch();
m_shapes.ReleaseDispatch();
这篇关于C++ COM EXCEL插入PDF的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!