向word和excel的页眉插入文字已经实现了,但是怎么样才能插入指定的图片呢

解决方案 »

  1.   

    在Excel 2003中新增了向工作表的页眉或页脚区域中添加图形文件的功能, 可以非常方便地在Excel工作表的页眉或页脚中增加图片。  解决办法:  步骤1:启动Excel 2003,打开需要进行操作的工作簿文件,然后选择“文件”菜单中的“页面设置”命令,打开“页面设置”对话框。  步骤2:选择“页眉/页脚”选项卡,接着单击“自定义页眉”按钮,打开“页眉”设置对话框。  步骤3:在下方的“左”编辑框中单击,然后单击“插入图片按钮”,打开“插入图片”对话框(如果要让页眉图片居中,则在“中”内进行)。  步骤4:在“插入图片”对话框找到需要插入到页眉中使用的图片文件后,单击“插入”按钮。这时可看到在“左”编辑区中出现“&[图片]”文字,同时工具按钮区中的“设置图片格式”按钮变为可用状态。  步骤5:单击“设置图片格式”按钮,打开“设置图片格式”对话框。根据需要对图片进行大小设置、位置放置、缩放、剪裁和调整。  步骤6:设置完成后单击两次“确定”按钮返回“页面设置”对话框。选择“页边距”选项卡,设置页边距参数。  步骤7:单击“确定”按钮返回Excel工作表编辑区中。
      

  2.   

    TO:1楼的兄弟,先谢了,我是想要C#代码操作的
      

  3.   

    WORD的页眉中插入图片已经实现了:Object oMissing = System.Reflection.Missing.Value; object path = "C:\\test.doc"; Application WordApp = new Application(); Document mydoc = WordApp.Documents.Open(ref path, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing); mydoc.ActiveWindow.ActivePane.View.SeekView = WdSeekView.wdSeekCurrentPageHeader; mydoc.ActiveWindow.ActivePane.Selection.InlineShapes.AddPicture("C:\\test.jpg", ref oMissing, ref oMissing, ref oMissing); 现在就剩下EXCEL的页眉中插入图片了
      

  4.   

    C#向Excel报表中插入图片的2种方法
    InsertPicture
    or
    Excel.Pictures.Inserthttp://blog.csdn.net/net_lover/archive/2007/07/23/1702797.aspx
      

  5.   

    TO:孟子兄,谢谢你的示例,我是想将图片插入到EXCEL的页眉中。
      

  6.   

    插入到哪应该都可以的,你找到页眉对象就可以操作了,至于代码,你可以通过下面的方法得到
    1,记录宏,然后插入页眉图片,看宏代码是什么,一般的做法是类似的
    2,参考MSDN的VBA参考手册或者Visual Studio Tools for the Microsoft Office System
    http://msdn.microsoft.com/zh-cn/library/e7ezs44a%28VS.80%29.aspx
    http://msdn.microsoft.com/zh-cn/library/bb726434%28office.12%29.aspx
    http://msdn.microsoft.com/en-us/library/bb190882%28office.11%29.aspx3,到 google上搜索,一般都能搜到的
      

  7.   

    Excel中页眉插入图片也解决了,代码如下://页眉添加图片
                        ((Microsoft.Office.Interop.Excel.Worksheet)wb.Sheets[i + 1]).PageSetup.RightHeaderPicture.Filename = FileName;
                        ((Microsoft.Office.Interop.Excel.Worksheet)wb.Sheets[i + 1]).PageSetup.RightHeader = "&G"; 还有最后一个问题,就是怎么给PDF文件的页眉添加图片了
      

  8.   

    excel 页眉添加图片 VC是怎样实现的呀