//插入图片
void COperExcel::XlsInsertPictrue(const CString &strPicPath,float xPos, float yPos,float picWidth, float picHeight)
{
if (!xlsAppIsInit())
{
return;
}
if (strPicPath.IsEmpty())
{
;//(_T("文件路径不能为空!"));
return;
}
const float fAccuracy = 0.0000000000;
if (xPos < fAccuracy || yPos < fAccuracy || picWidth < fAccuracy || picHeight < fAccuracy)
{
;//(_T("输入的参数必须大于等于0"));
return;
}
CShapes xlsShapes;
LPDISPATCH lpDisp = NULL;
lpDisp = m_xlsAppLication.get_ActiveSheet();
if (lpDisp == NULL)
{
return;
}
CWorksheet xlsWorkSheet;
xlsWorkSheet.AttachDispatch(lpDisp);
lpDisp = xlsWorkSheet.get_Shapes();
if (lpDisp == NULL)
{
return;
}
xlsShapes.AttachDispatch(lpDisp);
if (xlsShapes.m_lpDispatch == NULL)
{
return;
}
xlsShapes.AddPicture(strPicPath,false,true,xPos,yPos,10,10);
lpDisp = xlsShapes.get_Range(_variant_t((long)1));
CShape xlsShape;
if (lpDisp == NULL)
{
return;
}
xlsShape.AttachDispatch(lpDisp);
if (xlsShape.m_lpDispatch == NULL)
{
return;
}
xlsShape.put_Name(_T("xx"));
xlsShape.put_Width(picWidth);
xlsShape.put_Height(picHeight);
xlsShapes.ReleaseDispatch();
xlsShape.ReleaseDispatch();
xlsWorkSheet.ReleaseDispatch();
lpDisp = NULL;
}