以下代码将excel图表复制为图片并将其粘贴到PictureBox1中。
Dim ExcelWbk1 As Excel.Workbook
ExcelWbk1.ActiveChart.CopyPicture(Microsoft.Office.Interop.Excel.XlPictureAppearance.xlScreen, Microsoft.Office.Interop.Excel.XlCopyPictureFormat.xlBitmap)
PictureBox1.Image = CType(Clipboard.GetData(System.Windows.Forms.DataFormats.Bitmap), Bitmap)
现在,让我们做相反的事情。
如何从PictureBox1复制图像并粘贴到Excel?
以下链接可能会有所帮助...... https://msdn.microsoft.com/en-us/library/ms172505(v=vs.90).aspx
答案 0 :(得分:0)
试一试......
Dim xlApp As New Excel.Application
Dim wbkMyBook As Excel.Workbook
Dim shtMySheet As Worksheet
wbkMyBook = xlApp.Workbooks.Open(path to xls file)
xlApp.Visible = True
shtMySheet = wbkMyBook.Worksheets(1)
Clipboard.Clear()
Clipboard.SetData(Image, Me.PictureBox1.Image)
shtMySheet.Paste
wbkMyBook = Nothing
shtMySheet = Nothing
xlApp.Quit
xlApp = Nothing
答案 1 :(得分:0)
你可以使用这样的东西
Clipboard.SetImage(pictureBox1.Image)
ActiveSheet.Paste(ActiveSheet.Range("A1"))