110,537
社区成员
发帖
与我相关
我的任务
分享
Tables saptb = (Tables)ifunc.Tables;
Table tb1 = (Table)saptb.get_Item("itab");
byte[] image = SetImageToByteArray(ImgPath);//该方法是将指定路径的图片转换成二进制数组
byte[] imgbyte = new byte[1024];
int z = 1;
int y = 0;
tb1.AppendRow();
for (int i = 0; i < image.Length; i++)
{
imgbyte[y] = image[i];
if (y + 1 == 1024)
{
try
{
//tb1.set_Cell(z, "LINE", imgbyte); 这个写法报错
// tb1.set_Value(z, "LINE", imgbyte); 这个写法也报错
// tb1.AppendGridData(1, 1, 1, imgbyte); z一直是1,倒是可以传递进SAP,方法执行成功了,但是SAP收到图片后执行图片预览显示的时候,图片却是损坏的。
tb1.AppendGridData(z, 1, 1, imgbyte); //这个写法,第一行正常添加进table,但是z>1开始,就报错“Bad Index”
}
catch (Exception exx)
{
}
z++;
y = 0;
imgbyte = new byte[1024];
}
else
{
y++;
}
if (i == image.Length - 1 && image.Length % 1024 != 0)
{
//tb1.set_Cell(z, "LINE", imgbyte);
tb1.AppendGridData(z, 1, 1, imgbyte);
z++;
}
}
SAPFunctionsOCX.IParameter maktx = (SAPFunctionsOCX.IParameter)ifunc.get_Imports("RETURN");
//maktx.Value = "3";
ifunc.Call();
tB_CnnMsg.AppendText(maktx._Value.ToString() + '\n');