用VB中的控件显示Excel中的图表

来源:百度知道 编辑:UC知道 时间:2024/06/27 06:31:46
请问哪位大侠知道如何用VB中的image或picturebox控件显示excel中的图表(ChartObject),本人急用,不胜感谢!

Function Save_Excel_Data() As Boolean
Save_Excel_Data = False

Dim Excel_File As String
Dim ExcelSave As Boolean

On Error GoTo err1
CommonDialog1.FileName = ""
CommonDialog1.Filter = "EXCEL (*.xls)|*.xls|"
CommonDialog1.FilterIndex = 1
CommonDialog1.ShowSave

If Err <> 32755 Then
Excel_File = CommonDialog1.FileName

If Dir(Excel_File) <> "" Then Kill Excel_File

Set sf1 = CreateObject("Excel.Application")

sf1.Workbooks.Add
Set sf2 = sf1.Workbooks(1)
Set sf3 = sf2.ActiveSheet

Dim x(1 To 3) As Integer, y(1 To 3) As Integer
x(1) = 1
x(2) = 2
x(3) = 9
y(1) = 12
y(2) = 5
y(3) = 19

sf3.Cells(1, 1).Value = x(1)
sf3.Cells(2, 1).Value = x(2)
sf3.Cells(3, 1).Value = x(3)
sf3.Cells(1, 2).Value = y(1)
sf3.Cells(2, 2).Value = y(2)
sf3.C