Affichage feuille Excel

Thomeux Messages postés 58 Date d'inscription mercredi 15 mars 2006 Statut Membre Dernière intervention 14 janvier 2010 - 3 oct. 2006 à 11:05
ZedMaTrix Messages postés 178 Date d'inscription vendredi 25 octobre 2002 Statut Membre Dernière intervention 14 août 2008 - 26 oct. 2006 à 10:37
Bonjour,
Je développe actuellement un programme qui travaille sur des fichiers Excel. Je cherche a afficher le contenu d'une feuille excel pour vérifier que c'est bien le fichier sur lequel je dois travailler.
Je sais visualiser le contenu d'un fichier texte, mais je ne parviens pas a  faire le meme chose pour Excel.
si quelqu'un pouvait m'aider, ce serait sympa
Merci d'avance

7 réponses

cs_JMO Messages postés 1854 Date d'inscription jeudi 23 mai 2002 Statut Membre Dernière intervention 24 juin 2018 27
3 oct. 2006 à 12:43
 Bonjour,

J'ai trouvé cette source en .Net
http://www.vbfrance.com/codes/CODE-PERMETTANT-MANIPULER-OBJETS-EXCEL-NET_38534.aspx

jean-marc
0
Thomeux Messages postés 58 Date d'inscription mercredi 15 mars 2006 Statut Membre Dernière intervention 14 janvier 2010
3 oct. 2006 à 14:33
La source que vous m'avez  communiqué explique comment utliser les fonction de Excel via VB. Ce n'est pas ce que je désire faire, je désire visualiser dans une fenetre ou dans une liste la feuille excel pour savoir sur quelle valeur je vais travailler.
merci quand même.
Thom
0
cs_JMO Messages postés 1854 Date d'inscription jeudi 23 mai 2002 Statut Membre Dernière intervention 24 juin 2018 27
3 oct. 2006 à 16:21
 Bonjour à tous....

Est-ce qu'un exemple en vbs, wsh ou wmi ferait l'affaire ?

jean-marc
0
Thomeux Messages postés 58 Date d'inscription mercredi 15 mars 2006 Statut Membre Dernière intervention 14 janvier 2010
3 oct. 2006 à 17:17
je travailles en vb.net, mais je pense que j'arriverai a décripter ce que tu m'enverra.
thom
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
cs_JMO Messages postés 1854 Date d'inscription jeudi 23 mai 2002 Statut Membre Dernière intervention 24 juin 2018 27
3 oct. 2006 à 17:29
 Re,

dans ce lien pour jean-luc,  en vbs, j'affiche et modifie une feuille d'un classeur Excel.

jean-marc
0
Thomeux Messages postés 58 Date d'inscription mercredi 15 mars 2006 Statut Membre Dernière intervention 14 janvier 2010
3 oct. 2006 à 18:39
J'ai du mal m'expliquer.
Je sais travailler dans excel via vb.
Ce que je veux faire ce n'est pas afficher une feuille excel en ouvrant excel(ca je sais faire), ce que je souhaite c afficher le contenu d'une feuile excel dans une textbox, ou listbox, sans forcement ouvrir excel. c'est du même principe que je n'ai pas besoin d'ouvrir Word pour pouvoir afficher le contenu d'un fichier text dans une textbox. Si tu veux je cherche a visualiser le contenu de la feuille excel comme si c'étit une image.
J'ai été plus clair?
Merci quand meme!
Thom
0
ZedMaTrix Messages postés 178 Date d'inscription vendredi 25 octobre 2002 Statut Membre Dernière intervention 14 août 2008
26 oct. 2006 à 10:37
Salut Thomeux,

Ont est tout les deux dans la même situation, sauf que moi je veux inscrusterle workbook dans la form de VB6.

Bon sinon pour ton soucis, c'est asser simple.
Le but est d'utiliser un objet excel pour lire le contenue du fichier et le placer dans un Array. Dans le MSDN tu trouvera cela.
Il faut que tu cherche a "worksheet populate" dans la doc de MSDN.

Moi je te donne la doc du MSDN 6, je n'ai que ca, mais ca devrais te mettre sur la voie

Using an Excel Worksheet to Populate an Array
<object id= "alink_1" style="left: 10px; width: 64px; top: 57px; height: 18px;" type="application/x-oleobject" classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11" height="18" width="64"></object>

If you have data stored in an Excel worksheet, you can use the GetObject method to get a
reference to the workbook that contains the worksheet, then retrieve
the values using the reference. To first get the reference, the only argument
needed is the path to the workbook, as shown below:

' Place this code in the Declarations section.
Option Explicit
' If you are using Office 97, be sure to set a 
' reference to Microsoft Excel 8.0 Object Library.
' If you are using Office 95, set a reference to
' Microsoft Excel 5.0 Object Library, and declare 
' the variable as a Worksheet.
Dim wkbObj As WorkBook ' Declare an object variable.

Private Sub Form_Load()
   ' Then set the variable with the GetObject method.
   Set wkbObj = GetObject _
      ("C:\My Documents\MySpread.xls")
End Sub


Note    In order to use Excel objects, you must set
a reference to the Excel Objects library. To do this, click the Project menu,
then click References. Search for the Excel Objects library and double-click it.
Click OK. Also, note that if you're using GetObject with the Excel 5.0 Object
Library, you must declare the variable as a WorkSheet; if you are
using the Excel 8.0 Object Library, declare the variable as a WorkBook.

After setting a reference to the Excel object library, you can use the
reference to walk through the Excel object model, populating the array with
data from the worksheet. To do this, use the Range method in conjunction
with the Value property to get the data from any single cell in a
spreadsheet.

Dim arrPrices (1 to 7)
Dim i As Integer
For i  = 1 to 7
   ' Fill the array with seven values from column B of
   ' the worksheet.
   arrPrices(i) =  wkbObj.Worksheets(1) _
   .Range("B" &amp; i + 1).Value
Next i


If you're not familiar with Excel spreadsheets, the following figure shows
where the values are coming from.

Typical Excel Spreadsheet

The layout of a spreadsheet, and the method used to refer to its cells, also
maps conveniently to the method of referring to data points in the MSChart
control. For example, a "column" in a spreadsheet (as in column "B" in the
preceding illustration) corresponds to a "column" in the MSChart. And when you
create a multi-series chart, each column corresponds to a series. Similarly, the
"row" of a spreadsheet corresponds to the "row" in a "column" in the MSChart.
For this reason, it helps to engineer a chart with a spreadsheet in mind.

For example, just as we first created a multi-series chart by increasing the
dimensions of the array, we can now fill the array by using more than one column
of the worksheet.
In other words, to create a multi-series chart, we fill two (or more) columns of
the spreadsheet with numbers, and use the columns to fill an array, as
illustrated in the following code:

Dim arrData (1 to 7, 1 to 2)
Dim i As Integer
For i  = 1 to 7
   ' Values from column A fill the first series of the
   ' array. If these values are strings, they become 
   ' the labels for the rows. 
   arrData(i, 1) = wkbObj.Worksheets(1) _
   .Range("A" &amp; i + 1).Value

   ' Then values from column B fill the second.
   arrData(i, 2) = wkbObj.Worksheets(1) _
   .Range("B" &amp; i + 1).Value
Next i


Tip   Use the CurrentRegion property to return the
number of rows in an Excel column. You can then use this number to specify the
upper bound of the array's first dimension.

The preceding code, used in conjunction with the spreadsheet shown in the
figure above, will produce a chart that has each row labeled with the
appropriate day of the week.

Une fois que ton array est remplis, tu n'as plus qu'as faire une boucle sur la taille du array ( Ubound(du_array) pour avoir sa taille ) et tu n'as plus qu'a répartir les donnée dans ce que tu veux !

J'éspère que ca t'aura aidé

Parcontre si tu sais incruster une feuille excel dans une form VB6, comme fais Internet Explorer quand tu ouvre un fichier excel, ca m'interesse !!

ZedMaTriX
0
Rejoignez-nous