怎样在EXCEL中插入图片? 现在工程中已经实现打开EXCEL对象,直接利用workSheet.Cells[x,x]输入字符型数据,但如今要求在具体单元格中插入图片,请教各位高手如何实现??? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 /// <summary> /// 插入图片 /// </summary> /// <param name="fileName">图片文件名(带路径)</param> /// <param name="left">left</param> /// <param name="top">top</param> /// <param name="width">宽</param> /// <param name="height">高</param> public void InsertPicture(string fileName, float left,float top,float width,float height) { try { objSheet.Shapes.AddPicture(fileName,Microsoft.Office.Core.MsoTriState.msoTrue, Microsoft.Office.Core.MsoTriState.msoTrue,left,top,width,height); } catch { throw new Exception(""); } } 用宏录制一下你的手工操作,然后到VBA里面看一下,应该可以找到相关的代码的 按照Eddie005(♂) 暴赱 『零零伍』(︶︵︶) 的做法能够插入图片,但如何定位具体单元格的方法没有找到??? 前2天刚学会的,不过是vb的,看能翻译成C#不With ws.Cells(iRow, img_col) 'ws是个worksheet对象Set pic = .Parent.Pictures.Insert(pic_file_name) '搞不清除pic到底是什么对象,声明为object就行aspect = pic.Height / pic.Width '高宽比pic.Top = .Top + 2pic.Left = .Left pic.Width = .Width pic.Height = (pic.Width * aspect).RowHeight = pic.Height + 4End With 急急:怎么连接sql数据库 菜鸟求助 上传控件 进度条显示 急求给力解决方法!!!!!!!!!! 急!!!gridview问题求教 如何让dropdownlist空值显示? 这样的表结构,怎么以列表形式一行行显示出来 怎么设定再web页面上 敲下Enter键激发的按钮? 请教一个关于asp.net mvc 路由的问题 datagrid 中怎么把其中的一列做成超链接,并且传递该datagrid 中的某一个字段到另一个页面!! layui有人用吗,求解 怎样把服务器端的控件button 属性的提交属性设置为普通的按钮? 绑定数据的困惑
/// 插入图片
/// </summary>
/// <param name="fileName">图片文件名(带路径)</param>
/// <param name="left">left</param>
/// <param name="top">top</param>
/// <param name="width">宽</param>
/// <param name="height">高</param>
public void InsertPicture(string fileName,
float left,float top,float width,float height)
{
try
{
objSheet.Shapes.AddPicture(fileName,Microsoft.Office.Core.MsoTriState.msoTrue,
Microsoft.Office.Core.MsoTriState.msoTrue,left,top,width,height);
}
catch
{
throw new Exception("");
}
}
With ws.Cells(iRow, img_col) 'ws是个worksheet对象
Set pic = .Parent.Pictures.Insert(pic_file_name) '搞不清除pic到底是什么对象,声明为object就行
aspect = pic.Height / pic.Width '高宽比
pic.Top = .Top + 2
pic.Left = .Left
pic.Width = .Width
pic.Height = (pic.Width * aspect)
.RowHeight = pic.Height + 4
End With