I would like to add values to Excel using Visual FoxPro. The code is detailed below.
The problem that I have is that the whole range of cells are filled with the contents of the first element only, in the example below all cells contain "ORD 1"
Any help with this would be most appreciated.
Wayne
' Start a new workbook in Excel oExcel = CreateObject("Excel.Application") oBook = oExcel.Workbooks.Add oExcel.Visible=.t. ' Create an array with 3 columns and 100 rows Dim DataArray(100,3) For r = 1 To 100 DataArray(r, 1) = "ORD" + STR(r,6,0) DataArray(r, 2) = RAnd() * 1000 DataArray(r, 3) = DataArray(r, 2) * 0.7 Next oSheet = oBook.Worksheets(1) ' Transfer the array to the worksheet starting at cell A2 oSheet.Range("A2").Resize(100, 3).Value = DataArray ' Save the Workbook and Quit Excel oBook.SaveAs("C:Book1.xls") oExcel.Quit


Reply With Quote
