|
pdtoxls=function(){
var excel = com.CreateObject("Excel.Application")
excel.Visible = true; //使Excel窗口可见
excel.alerts = true; //关闭所有操作提示
book = excel.WorkBooks.Open( io.fullpath("\dll\exp.xls") )
var sheet = excel.ActiveWorkbook.Sheets(1);
pidlist=winform.checklist.text;
pidlist=string.replace(pidlist,"\[\d+\]",'');
sql="SELECT id,yipartsid,part,eng_unit,oe,number,eng_note,makes,pic FROM product where id in("+pidlist+") order by id limit "+start+","+pgsize;
//io.print(sql);
row=7;
for id,yipartsid,part,unit,oe,number,eng_note,makes,pic in sqlConn.each(sql) {
//excel.ActiveSheet.Range('B'+row).Select();
img=io.fullpath('/res/pic/small/'+pic);
io.print(img);
sheet.Cells(row,1).Select();
sheet.Application.ActiveWindow.Zoom = 100;
pleft=sheet.Range('A'+row).left;
ptop=sheet.Range('A'+row).Top;
io.print(pleft+'|'+ptop);
sheet.Shapes.AddPicture(img,0,-1,pleft,ptop,75.4,75.4);
sheet.Cells(row,3).Value2=PART[part];
sheet.Cells(row,4).Value2=oe;
sheet.Cells(row,5).Value2=unit;
sheet.Cells(row,6).value2 =getpdnum(id) ;
//sheet.Rows(row+':'+row).
//sheet.rows(3,3).insert();
// book.Selection.Insert Shift=1;
row++;
sheet.Range(row+':'+row).insert(_xlShiftDown);
}
//var path = fsys.dlg.save('EXCEL文件|*.xls|所有文件|*.*|CSV文件|*.csv','保存xls到');
//if(path)
// book.SaveAs(path);
//excel.Quit(); //退出
}
这是我将产品数据插入到excel中的部分代码
sheet.Shapes.AddPicture(img,0,-1,pleft,ptop,75.4,75.4); 这个是调用excel往里面插入图片。
expression.AddPicture(FileName, LinkToFile, SaveWithDocument, Left, Top, Width, Height) 这是函数参考。
但是我运行了,却发现left,top,width,height 这个值传过去的值,不生效。
所以图片都无法出现在我想出现的地方。调了两天了,一直没结果。
|
|