Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Need Excel properites/functions with descriptions
Message
From
12/12/2001 13:43:46
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
11/12/2001 13:59:55
General information
Forum:
Visual FoxPro
Category:
ActiveX controls in VFP
Miscellaneous
Thread ID:
00592725
Message ID:
00593414
Views:
35
>I installed MSDN with Vb but dont have that file and I only have VFP6
>I'm just trying to open a file.xls and then get the total number
>of rows,columns and then loop from top to bottom and set each variable
>and insert into Fox db ..... VS append from ? type xls which is
>not working right.
>
>Any ideas on these view variables?
>
>thanks,
>
>Ronnie

Ronnie,
I didn't mean MSDN. It's separate with Office. Check your office installed components.

Yes, append from has problems.
lcExistingFile = "FullPathIncludingXLSExtension"
oExcel = createobject('Excel.Application')
with oExcel
 .Workbooks.Open(lcExistingFile)
 with .ActiveWorkBook.ActiveSheet
   with .UsedRange
     lnColumns = .Columns.Count
     lnRows = .Rows.Count
   endwith
   If lnRows * lnCols <= 65000
      Dimension aExcelData[lnRows,lnCols]
   Else
      Dimension aExcelData[int(65000/lnCols),lnCols]
   Endif
   For ix = 1 to lnRows
      For jx = 1 to lnCols
         aExcelData[ix, jx] = .Cells(ix,jx).Value
      Endfor
   Endfor
 endwith
 .quit && Got data into array - quit excel
endwith
However this has shortcomings like using automation to read values cell by cell. Automation is slow so do as much as you can on VFP side. There are many alternatives depending on how your data looks. A simple one is to save from excel as a DBF :
lcExistingFile = "FullPathIncludingXLSExtension"
lcDBF="FullpathAndFilename_DBFToSave"
#define xlDBF3  8
oExcel = createobject('Excel.Application')
with oExcel
 .Workbooks.Open(lcExistingFile)
 .ActiveWorkBook.SaveAs(lcDBF, xlDBF3) && Save as a dBaseIII/Fox2x file
 .Quit
endwith
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform