2个回答
展开全部
给你个原创函数吧,第一次发布
Private Sub MSChart2Excel(MMSChart As MSChart, StartRowNumber As Integer, StartColNumber As Integer)
Dim XlApp As New Excel.Application
Dim XlBook As New Excel.Workbook
Dim XlSheet As New Excel.Worksheet
Set XlBook = XlApp.Workbooks.Add
Set XlSheet = XlBook.Worksheets(1)
XlApp.Visible = True
XlSheet.Range(XlSheet.Cells(StartRowNumber, StartColNumber), XlSheet.Cells(MMSChart.RowCount, MMSChart.ColumnCount)).Value = MMSChart.ChartData
XlApp.Charts.Add
XlBook.ActiveChart.ChartType = xlColumnClustered
XlBook.ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range(XlSheet.Cells(StartRowNumber, StartColNumber), XlSheet.Cells(MMSChart.RowCount, MMSChart.ColumnCount)) ', PlotBy:=xlColumns
XlBook.ActiveChart.Location Where:=xlLocationAsObject, Name:="Sheet1"
End Sub
Private Sub Command1_Click()
MSChart2Excel MSChart1, 1, 1
End Sub
Private Sub Form_Load()
MSChart1.RowCount = 8
MSChart1.ColumnCount = 8
For i = 1 To MSChart1.RowCount
MSChart1.Row = i
For j = 1 To MSChart1.ColumnCount
MSChart1.Column = j
MSChart1.Data = i * j
Next j
Next i
End Sub
Private Sub MSChart2Excel(MMSChart As MSChart, StartRowNumber As Integer, StartColNumber As Integer)
Dim XlApp As New Excel.Application
Dim XlBook As New Excel.Workbook
Dim XlSheet As New Excel.Worksheet
Set XlBook = XlApp.Workbooks.Add
Set XlSheet = XlBook.Worksheets(1)
XlApp.Visible = True
XlSheet.Range(XlSheet.Cells(StartRowNumber, StartColNumber), XlSheet.Cells(MMSChart.RowCount, MMSChart.ColumnCount)).Value = MMSChart.ChartData
XlApp.Charts.Add
XlBook.ActiveChart.ChartType = xlColumnClustered
XlBook.ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range(XlSheet.Cells(StartRowNumber, StartColNumber), XlSheet.Cells(MMSChart.RowCount, MMSChart.ColumnCount)) ', PlotBy:=xlColumns
XlBook.ActiveChart.Location Where:=xlLocationAsObject, Name:="Sheet1"
End Sub
Private Sub Command1_Click()
MSChart2Excel MSChart1, 1, 1
End Sub
Private Sub Form_Load()
MSChart1.RowCount = 8
MSChart1.ColumnCount = 8
For i = 1 To MSChart1.RowCount
MSChart1.Row = i
For j = 1 To MSChart1.ColumnCount
MSChart1.Column = j
MSChart1.Data = i * j
Next j
Next i
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |