>Hello everyone,
>
>I have to fill a graph in Excel with data. But I do not know how I can do it.
>The code I have until now is:
>
>#DEFINE xlEdgeBottom 9
>#DEFINE xlMedium -4138
>#DEFINE xlLandScpae 2
>#DEFINE xlWorkBookNormal -4143
>#DEFINE xlBar 2
>
>oExcel=CREATEOBJECT("Excel.Application")
>oWorkBook=oExcel.WorkBooks.Open(m_excelbestand)
>
>FOR m_teller=1 TO 4
> oWorkBook.ActiveSheet.Rows(1).Insert
>ENDFOR
>
>oWorkBook.ActiveSheet.Range("A5:J5").Font.Bold=.T.
>oWorkBook.ActiveSheet.Range("A5:J5").Borders(xlEdgeBottom).Weight=xlMedium
>
>FOR m_teller=4 TO m_fieldcount
> m_cel='"'+CHR(64+m_teller)+ALLTRIM(STR(m_regelnr))+'"'
> m_formule="="+CHR(64+m_teller)+ALLTRIM(STR(m_regelnr-1))+;
> "/("+CHR(67)+ALLTRIM(STR(m_regelnr-1))+;
> "/100)"
> oWorkBook.ActiveSheet.Range(&m_cel).Value=m_formule
>ENDFOR
>
>OWorkBook.ActiveSheet.Range("A1:Z200").Columns.Autofit()
>
>oWorkSheet1=oWorkBook.WorkSheets[1]
>oGraphSheet=oWorkBook.WorkSheets.Add(,oWorkSheet1)
>
>oWorkBook.WorkSheets["Blad1"].Name="Grafiek"
>
>oChart=oExcel.Sheets[2].ChartObjects.Add(45.7, 173.2, 319.5, 190.5)
>oChart.Activate()
>
>[Here I have to fill the graph with data from another sheet........]
>
>oExcel.DisplayAlerts=.F.
>oExcel.ActiveSheet.SaveAs(m_excelbestand, xlWorkBookNormal)
>oWorkBook.Save()
>oExcel.Quit()
>RELEASE oExcel
>
>Can anybody please tell me how I can give the range of data and the type of graph and maybe other parameters that I need?
>
>Thanx in advance
>Ron :o)
Hi Ron,
You could either create the chat with ChartWizard at once or later set data source :
oChart = .ChartObjects.Add(200, 200, 500, 200)
oChart.Chart.chartwizard(.Range(.Cells(1,1),.Cells(4,3)), ;
xl3DColumn,4,1,0,1,1,"","","","")
oChart.Chart.SetSourceData(.Range(.Cells(3,3),.Cells(8,6)),xlColumns)
OWorkBook.ActiveSheet.Range("A1:Z200").Columns.Autofit()
oWorkSheet1=oWorkBook.WorkSheets[1]
oGraphSheet=oWorkBook.WorkSheets.Add(,oWorkSheet1)
oWorkBook.WorkSheets["Blad1"].Name="Grafiek"
oChart=oExcel.Sheets[2].ChartObjects.Add(45.7, 173.2, 319.5, 190.5)
#define xlColumns 2
oChart.Chart.SetSourceData(oWorkSheet1.Range("A1:Z200"),xlColumns)
Cetin