Spreadsheet et Chartspace

cm75201 Messages postés 11 Date d'inscription samedi 14 août 2004 Statut Membre Dernière intervention 20 septembre 2004 - 15 août 2004 à 00:49
mad_kad Messages postés 23 Date d'inscription mercredi 9 février 2005 Statut Membre Dernière intervention 22 août 2005 - 6 avril 2005 à 19:21
Bonjour, j'aimerai avoir un exemple de programme pour réaliser une courbe à partir de données inscrites dans un "Spreadsheet" dans un "Chartspace".

Pour l'instant j'arrive à récupérer un fichier texte dans le spreadsheet mais je n'arrive pas coller la courbe.

Si quelqu'un peux me mettre sur la voie ! ! Merci

1 réponse

mad_kad Messages postés 23 Date d'inscription mercredi 9 février 2005 Statut Membre Dernière intervention 22 août 2005
6 avril 2005 à 19:21
ça pourrais bien t'aider :


Sub Window_Onload()<?xml:namespace prefix o ns "urn:schemas-microsoft-com:office:office" />


' This example starts by putting the data into Spreadsheet1. Normally,


' the data would already be loaded, but this code was added for completeness.


Spreadsheet1.ActiveSheet.Cells.Clear


Spreadsheet1.ActiveSheet.Cells(2, 1).Value = "White"


Spreadsheet1.ActiveSheet.Cells(3, 1).Value = "Black"


Spreadsheet1.ActiveSheet.Cells(4, 1).Value = "Asian"


Spreadsheet1.ActiveSheet.Cells(5, 1).Value = "Latino"





Spreadsheet1.ActiveSheet.Cells(1, 2).Value = "Perot"


Spreadsheet1.ActiveSheet.Cells(2, 2).Value = 0.2


Spreadsheet1.ActiveSheet.Cells(3, 2).Value = 0.06


Spreadsheet1.ActiveSheet.Cells(4, 2).Value = 0.17


Spreadsheet1.ActiveSheet.Cells(5, 2).Value = 0.13





Spreadsheet1.ActiveSheet.Cells(1, 3).Value "<?xml:namespace prefix st1 ns = "urn:schemas-microsoft-com:office:smarttags" /><st1:City><st1:place>Clinton</st1:place></st1:City>"


Spreadsheet1.ActiveSheet.Cells(2, 3).Value = 0.38


Spreadsheet1.ActiveSheet.Cells(3, 3).Value = 0.82


Spreadsheet1.ActiveSheet.Cells(4, 3).Value = 0.28


Spreadsheet1.ActiveSheet.Cells(5, 3).Value = 0.62





Spreadsheet1.ActiveSheet.Cells(1, 4).Value = "Bush"


Spreadsheet1.ActiveSheet.Cells(2, 4).Value = 0.42


Spreadsheet1.ActiveSheet.Cells(3, 4).Value = 0.12


Spreadsheet1.ActiveSheet.Cells(4, 4).Value = 0.55


Spreadsheet1.ActiveSheet.Cells(5, 4).Value = 0.25





' Clear the contents of the chart workspace. This removes


' any old charts that may already exist and leaves the chart workspace


' completely empty. One chart object is then added.


ChartSpace1.Clear


ChartSpace1.Charts.Add


Set c = ChartSpace1.Constants





' Set the chart DataSource property to the spreadsheet.


' It is possible to specify multiple data sources, but this example uses only one.


ChartSpace1.DataSource = Spreadsheet1





' Add three series to the chart.


ChartSpace1.Charts(0).SeriesCollection.Add


ChartSpace1.Charts(0).SeriesCollection.Add


ChartSpace1.Charts(0).SeriesCollection.Add





' Connect the chart to data by specifying spreadsheet cell references


' for the different data dimensions. Notice that the SetData method uses


' a data source index of 0; this is the first data source, which was previously


' set to the spreadsheet. If you had created multiple data sources,


' you could specify the index to any item in the WCDataSources collection for the


' data source index. For example, if two spreadsheet controls were attached to this


' chart workspace, you could set data from the first control using index 0


' and set data from the second control using index 1.





' Notice that the series name is also bound to a spreadsheet cell. Changing


' the contents of the cell "B1" will also change the name that appears in the legend.


' If you don't want this behavior, set SeriesCollection(0).Caption instead of


' using the SetData method to bind the series name to the spreadsheet.





' Series one contains election data for Perot.


' Bind the series name, the category names, and the values.


ChartSpace1.Charts(0).SeriesCollection(0).SetData c.chDimSeriesNames, 0, "B1"


ChartSpace1.Charts(0).SeriesCollection(0).SetData c.chDimCategories, 0, "A2:A5"


ChartSpace1.Charts(0).SeriesCollection(0).SetData c.chDimValues, 0, "B2:B5"





' Series two contains election data for <st1:City><st1:place>Clinton</st1:place></st1:City>.


ChartSpace1.Charts(0).SeriesCollection(1).SetData c.chDimSeriesNames, 0, "C1"


ChartSpace1.Charts(0).SeriesCollection(1).SetData c.chDimCategories, 0, "A2:A5"


ChartSpace1.Charts(0).SeriesCollection(1).SetData c.chDimValues, 0, "C2:C5"





' Series two contains election data for Bush.


ChartSpace1.Charts(0).SeriesCollection(2).SetData c.chDimSeriesNames, 0, "D1"


ChartSpace1.Charts(0).SeriesCollection(2).SetData c.chDimCategories, 0, "A2:A5"


ChartSpace1.Charts(0).SeriesCollection(2).SetData c.chDimValues, 0, "D2:D5"





' Make the chart legend visible, format the left value axis as percentage,


' and specify that value gridlines are at 10% intervals.


ChartSpace1.Charts(0).HasLegend = True


ChartSpace1.Charts(0).Axes(c.chAxisPositionLeft).NumberFormat = "0%"


ChartSpace1.Charts(0).Axes(c.chAxisPositionLeft).MajorUnit = 0.1


End Sub
0
Rejoignez-nous