Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Create a Excel file ?
Message
De
18/02/2001 09:37:08
 
 
À
18/02/2001 09:00:33
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00477104
Message ID:
00477107
Vues:
25
Easily done through OLE Automation. To learn about it, there are references in MSDN (Excel's Object Model), plus you can get a copy of an excellent book, "Microsoft Office Automation with isual FoxPro" by Tamar Granor and Della Martin.

Another easy way to learn is to create a recording macro in Excel and do what you want to accomplish. Then look at the generated VBA code from the macro. It does not produce the most efficient code but VBA is easy to translate to VFP and will teach you most of what you need to learn.

To see the generated code, open the VBA project with ALT-F11 and look for Module1 under VBA Project|Modules.
oExcel = CreateObject("Excel.Application")
oExcel.Visible=.t.
oExcel.SheetsInNewWorkBook=3   && default
oWorkbook = oExcel.Workbooks.Add
oWorkbook.Sheets("Sheet1").Select
oWorkbook.Sheets("Sheet1").Name = "MyPage1"
oWorkbook.Sheets("Sheet2").Select
oWorkbook.Sheets("Sheet2").Name = "MyPage2"
oWorkbook.Sheets("MyPage1").Select
oWorkbook.Range("A1").Select
oWorkbook.ActiveCell.FormulaR1C1 = "page 1 - 101"
oWorkbook.Range("B1").Select
oWorkbook.ActiveCell.FormulaR1C1 = "page 1 - 102"
oWorkbook.Sheets("MyPage2").Select
oWorkbook.Range("A1").Select
oWorkbook.ActiveCell.FormulaR1C1 = "page 2 - 201"
You can also see a similar example in the Wiki at:
http://fox.wikis.com/wc.dll?Wiki~AutomationExamples~VFP

HTH


>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>1. how to crate a Excel file ( that with 3 sheets, as like as the blank worksheet when i run EXCEL )
>
>2. how can i define the number of sheet at that Excel ?
>
>3. how can i define the name of sheet1, sheet2....3
>
>4. after created, how can i change the ACTIVE SHEET ?
> ex. i want to put some value into
> .cell(1,1) = "page 1 - 101" into sheet1
> .cell(1,2) = "page 1 - 102" into sheet1
> .cell(1,1) = "page 2 - 201" into sheet2
> .cell(1,2) = "page 2 - 201" into sheet2
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>


Alex Feldstein, MCP, Microsoft MVP
VFP Tips: English - Spanish
Website - Blog - Photo Gallery


"Once again, we come to the Holiday Season, a deeply religious time that each of us observes, in his own way, by going to the mall of his choice." -- Dave Barry
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform