Le forum (ô combien francophone) des utilisateurs de Powerbuilder.
Bonjour !
La question du jour :
la syntaxe
xlsheet.Workbooks.add(ls_file) me permet d'inclure dans Excel via un OLE le fichier ls_file.
Mais est-il possible de l'inclure à un endroit bien précis de la feuille (après un premier bloc de données par exemple) ou dauns une autre feuille du classeur ?
Hors ligne
http://www.sybase.com/detail?id=1013157 ca peut etre ?
Hors ligne
pick ouic a écrit:
http://www.sybase.com/detail?id=1013157 ca peut etre ?
Je voulais éviter de faire une boucle justement
Hors ligne
ou alors, quelque chose dans ce script ?
OLE automation in PowerBuilder 6.x, 7.x and 8.x has improved performance from the 5.x version. Data can be copied to Excel. This is a sample application that will copy all columns and rows to MS Excel.
Using OLE automation in PowerBuilder 6.x, 7.x and 8.x you can copy data from a datawindow to an Excel 8, Excel 97 or Excel 2000 spreadsheet much faster than with previous versions of PB. There is also a sample application available for download that will copy all columns and rows to a MS Excel spreadsheet.
The sample copies Datawindow Row 1 ,Column 1 to MS Excel Row 1 , Column 1 etc....
The script can be modified to copy only the desired columns/rows.
A template xls file could be opened and saved to a different xls filename, preserving the template.
Uncomment the Save or SaveAs lines accordingly.
The sample pbl provided uses the EAS DEMO DB's Employee table.
47867.zip is an sample PBL for techdoc 47867 "Copying Datawindow data to Microsoft Excel using OLE Automation"
The following script code is located in the "Copy DW Data to Excel using OLE Automation"
button , on the only window in the pbl. The example pbl is currently setup to open the file "c:\file1.xls"
Modify the path/filename or create file1.xls in the c:\ directory. The file can be an empty xls file.
Code: pb
long numcols , numrows , c, r OLEObject xlapp , xlsub int ret // Set the # of columns and rows to process // Currently Set to copy the entire DW numcols = long(dw_1.Object.DataWindow.Column.Count) numrows = dw_1.RowCount() // Create the oleobject variable xlapp xlApp = Create OLEObject // Connect to Excel and check the return code ret = xlApp.ConnectToNewObject( "Excel.Sheet" ) if ret < 0 then MessageBox("Connect to Excel Failed !",string(ret)) return end if // Open a particular Excel file xlApp.Application.Workbooks.Open("c:\file1.xls") //,false,true // Make Excel visible xlApp.Application.Visible = true // Resolve the Excel reference once // This technique shortens the script and improves performance xlsub = xlapp.Application.ActiveWorkbook.Worksheets[1] // Loop thru the Datawindow and Excel sheet // The for/next loop copies all rows for each column For c = 1 to numcols For r = 1 to numrows xlsub.cells[r,c] = dw_1.object.data[r,c] Next Next // Save opened file //xlApp.Application.Activeworkbook.Save() // SaveAs a different filename //xlApp.Application.Activeworkbook.SaveAs("c:\file2.xls") // clean up xlApp.DisConnectObject() Destroy xlapp
Hors ligne
Je vais regarder ça. Merci.
Hors ligne
Je reviens à l'attaque avec mes OLE Excel.
Y-a-t-il un lien quelquepart qui donen de manière exhaustive toutes les commandes qu'on peut utiliser dans PB pour jouer avec les OLE Excel. Par exemple comment faire pour insérer une nouvelle feuille dans un classeur, renommer une feuille etc etc... ?
Hors ligne
Installes cet outil, OLEViewer http://pbadonf.fr/forum/viewtopic.php?id=106
avec ca, tu pourras voir les differentes fonctions des dlls de excel...
sinon, il existe peut etre un SDK Excel ?
Bon courage
et tiens nous au courant !
Hors ligne
bon je vais voir ce que je peux faire, merci
Hors ligne