
23/08/2006, 23:12
|
| | Fecha de Ingreso: agosto-2006
Mensajes: 1
Antigüedad: 18 años, 8 meses Puntos: 0 | |
Excel y Visual Basic Estoy desarrollando un programa para poder graficar y obtener resultados de unas llamadas a un centro de ayuda Psicológico para jóvenes, se necesitan saber las estadísticas de cómo funciona la línea mes con mes.
Para eso registro todas las llamadas en una base de datos y atravez de una consulta SQL obtengo los datos y los exporto a Excel mi pregunta es la siguiente, quiero que esos datos se grafiquen, pero no puedo usar el componente chart por que es muy basico, así que necesito el tipo de grafica Pie o circulo tridimensional que se separa como si fuera un pay.
Como hago esto, como le hago para no usar componentes ni nada extra, sino que a través de Basic y usando la llamada a Excel me pueda graficar, que función uso?
Les dejo mi código que estoy usando Dim cnn As ADODB.Connection
Dim rst As ADODB.Recordset
Dim strCnn As String
Set cnn = New ADODB.Connection
FechaInicio1 = "#" & Format$(FechaInicio.Text, "yyyy/mm/dd") & "#"
FechaFin1 = "#" & Format$(FechaFin.Text, "yyyy/mm/dd") & "#"
strProvider = "Provider=Microsoft.Jet.OLEDB.4.0;"
strSource = "Data Source=" & App.Path & "\hidalgo.mdb;"
strConnectionGenericRecordset = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strServerDBPath & "\GenericRecordset.mdb;Persist Security Info=False"
strConnection = strProvider & strSource & "Persist Security Info=False"
cnn.Open strConnection
'-----------------------------------------------------------------------------
' Lineas SQL
LMotivo = "SELECT First(Datos.Edad) AS EdadCampo, Count(Datos.Edad) AS NúmeroDeDuplicados From Datos Where (((Datos.Fecha) >= " & FechaInicio1 & " And (Datos.Fecha) <= " & FechaFin1 & "))GROUP BY Datos.Edad Having (((Count(Datos.Edad)) >= 1))ORDER BY First(Datos.Edad) DESC;"
rst.Open LEdad, cnn, adOpenForwardOnly, adLockReadOnly
'Set Grind.DataSource = rst
Dataedad = rst.GetRows
NEdad = UBound(Dataedad, 2) + 1
rst.Close
Set rst = Nothing
Set mobjExcel = New Excel.Application
Dim objWorkbook As Excel.Workbook
' The Excel application object has numerous properties
' that you can set. Like the caption and so on.
' Show the Application
mobjExcel.Visible = True
' Create a workbook object to set it's properties
Set objWorkbook = mobjExcel.Workbooks.Add
' Clear the reference
Set objWorkbook = Nothing
'llenar datos
Dim objExcelSheet As Excel.Worksheet
Dim i As Long
Dim Campo As Byte
Dim Duplicados As Byte
Dim A As Byte
Dim B As Byte
Dim C As Byte
Dim D As Byte
Dim E As Byte
Dim F As Byte
Dim G As Byte
Dim H As Byte
Campo = 0
Duplicados = 1
A = 1
B = 2
C = 3
D = 4
E = 5
F = 6
G = 7
H = 8
' Set the Sheet Object to the Active Sheet
Set objExcelSheet = mobjExcel.ActiveWorkbook.ActiveSheet
With objExcelSheet
.Name = "Datos"
.Cells(1, A) = "Edad"
.Cells(1, B) = "Total"
For i = 1 To NEdad
.Cells(1 + i, A) = Dataedad(Campo, i - 1)
.Cells(1 + i, B) = Dataedad(Duplicados, i - 1)
Next i
End With
Ens sub
De antemano muchas gracias al que me pueda ayudar |