[英]How to copy image from PictureBox1 to excel?
Following code copies excel chart as picture and paste it into PictureBox1. 以下代码将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)
Now, lets do the opposite. 现在,让我们做相反的事情。
How to copy image from PictureBox1 and paste to the excel? 如何从PictureBox1复制图像并将其粘贴到Excel?
Following link may help... https://msdn.microsoft.com/en-us/library/ms172505(v=vs.90).aspx 以下链接可能会有所帮助... https://msdn.microsoft.com/zh-cn/library/ms172505(v=vs.90).aspx
Give this a try... 试一试......
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
You can use something like this 你可以使用这样的东西
Clipboard.SetImage(pictureBox1.Image)
ActiveSheet.Paste(ActiveSheet.Range("A1"))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.