Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Exporting to an Excel template file
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 6 SP5
OS:
Windows '98
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01032719
Message ID:
01032724
Views:
25
>I have an EXCEL template file, WireCertsReport.XLS, which I would like to append to from Visual FoxPro, inserting where appropriate certain datra items, then several rows of data.
>
>
>                          Name of Company
>                           Division Name
>                    Wire Certification Test Report
>
>Customer:               Joe Schmo's Construction   Date:  07/12/2005
>
>Material Description:   .120 HS CLASS A            Wire Order #: 441090
>
>Specification:          ASTM-475                   Cust Order #: 101078
>
>HEAT#       C       Mn      P       S      Si
>30199      0.70    0.66   0.011   0.018   0.194
>
>STAND #   DIAMETER BREAK  TENSILE ELONG  ZINC WT   REMARKS
>           (IN.)   (LBF)   (KSI)   (%)   (OZ.FT ^2)
>
>326562    0.1188   2113   191.0    5.6   0.880     ACTUAL
>326558    0.1193   2088   187.0    5.6   1.004
>
>
>Am I going to have to resort to low-level file functions to do this in EXCEL?
>
>All of the data is to be in an EXCEL file when this is done. Part of the data will be loaded into the EXCEL file from a FoxPro table, row by row, but the header data needs to be placed in specific locations (cells).
>
>Has anyone ever done anything like this?

Cecil
Try
LOCAL oxl as "Excel.Application"

oxl = CreateObject("Excel.Application")
if vartype(oxl) != "O"
  * could not instantiate Excel object
  return .F.
endif

* make excel visible during development
*oExcel.visible = .T.

* open the workbook
oxl.SheetsInNewWorkBook = 1
oWorkbook = oxl.Workbooks.Open("WireCertsReport.XLS")

* to rename the Sheet
oActiveSheet = oxl.ActiveSheet
oActiveSheet.Name = "NewSheetTitle"

* add a row 
oxl.Range("A1").Select
oxl.Selection.Insert( 3 )

* play with values in specific cells
oxl.Cells(1,1).Value = "Bla bla bla"
oxl.Cells(1,5).Value = 12345

* find address of last occupied cell
lcLastCell = oxl.ActiveCell.SpecialCells(11).Address()

* save Excel
oWorkbook.Save()
HTH
Jaime
Why do programs stop working correctly as soon as you leave the Fox?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform