код рабочий, Ax2012, Office 2013
X++:
public SysExcelShape_NET addPicture(str _file,
real _width,
real _height,
boolean _rightSide = false
boolean _center = false
)
{
Microsoft.Office.Interop.Excel.Worksheet curWorksheet;
Microsoft.Office.Interop.Excel.Shapes shapes;
Microsoft.Office.Interop.Excel.Shape shape;
System.Object linkToFile;
System.Object saveWithDocument;
System.Single left;
System.Single top;
System.Single width;
System.Single height;
real leftReal;
real widthRangeReal;
Microsoft.Office.Interop.Excel.Borders borders;
Microsoft.Office.Interop.Excel.Border borderTop;
new InteropPermission(InteropKind::ClrInterop).assert();
linkToFile = 0;
saveWithDocument = 1;
left = range_net.get_Left();
top = range_net.get_Top();
width = _width;
height = _height;
if (_rightSide)
{
leftReal = left;
widthRangeReal = range_net.get_Width();
left = leftReal + widthRangeReal - _width;
}
else
if (_center)
{
leftReal = left;
widthRangeReal = range_net.get_Width();
left = leftReal + (widthRangeReal / 2) - (_width / 2);
}
borders = range_net.get_Borders();
borderTop = borders.get_Item(Microsoft.Office.Interop.Excel.XlBordersIndex::xlEdgeTop);
curWorksheet = range_net.get_Worksheet();
shapes = curWorksheet.get_Shapes();
shape = shapes.AddPicture(_file,
linkToFile,
saveWithDocument,
left,
top,
width,
height);
if (borderTop.get_Weight())
{
shape.IncrementTop(1);
}
return SysExcelShape_NET::construct(version, shape);
}