Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Exporting to Excell
Message
From
19/05/2005 11:17:53
 
 
To
19/05/2005 11:01:18
Brian O'Donovan
Crescent Computers
Cork, Ireland
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 6
OS:
Windows XP
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01015828
Message ID:
01015841
Views:
27
>I am having difficulty export a dbf file with 25,000 records out to excell. When I run the export routine, only about 16000 records actually appear in the excell spreadsheet. Any ideas ?
>
>Brian

Brian

16K restriction, now lifted to 64K in 9 (as I understand). All covered about 2 months ago on the UT. I wrote a digest for a colleague, see below:

HTH

Terry

___________________________________
Hi,

I have a dbf that i want to export to a excel file. I open the dbf and its contains 33372 records. when i do export to filename type xls (or xl5) only 16384 records are exported to the xls file.

Is that a know problem ? And if so... are there any sollutions ? Are there any other ways to export a dbf to an excel file without losing information ?

Thnx
-----------------------
VFP 7 is limited to 16 384 records for Excel file. You can use a CSV file to bypass this limitation:
COPY TO test.csv TYPE csv
Upgrading to VFP 9 will also resolve your problem.

Note that both options have another limitation: 65 535 records max.

-----------------------
You can copy out to CSV and than use Excel automation to conver to XLS. Sample code
SELECT mytable
lcCsvFile = "H:\temp\something.csv"
lcExcelName = FORCEEXT(lcCsvFile, "XLS")
COPY TO (lcCsvFile) TYPE CSV
oExcel = CreateObject("Excel.Application")
*oExcel.Visible = .T.
oWorkbook = oExcel.Workbooks.Open(lcCsvFile)
IF FILE(lcExcelName)
ERASE (lcExcelName)
ENDIF
xlExcel5 = 39
oWorkbook.SaveAs(lcExcelName,xlExcel5)
oExcel.Quit()

* Launch Excel with file created
RUN "&lcExcelName"
------------------------------------
Above code works fine and in the cvs file are all the records. But my excel file is limited again to the 16384 records...>>So is it possible that the problem is situated in excel and not in vfp ?The versions of Excel earlier than 8.0 (Excel 97) display only the first 16,384 rows and cannot import files containing more than 32,767 rows.
------------------------------------
CETIN's SOLN. VFP versions have some limitations with type xls,xl5 (xls is worse - version 2.0).Solution is not to use xl* but something like csv,dbf or automation.CSV and Fox2x dbf are natively recognizable by excel. ie:copy to myFile.csv type csvcopy to myFile.dbf type fox2xAutomation approach is more trustable and you can either provide a live data or snapshot (as does copy to) to excel including memo fields, reccount over 64K excel row limit (good for Pivot tables). ie: A snapshot version (ODBC or OLEDB is fine):Local oRS as AdoDB.Recordset,oRS2 as AdoDB.Recordset,oCon as AdoDB.Connection
oCon = CreateObject('ADODB.connection')
oCon.ConnectionString = "Provider=VFPOLEDB;Data Source="+_samples+"data\testdata.dbc"
oCon.Open
oRS = oCon.Execute('select * from employee')
oRs.Save('disconnectme.rst')

oRS2 = CreateObject('ADODB.Recordset')
oRs2.Open('disconnectme.rst')

oExcel = Createobject('Excel.Application')
With oExcel
.Workbooks.Add
.Visible = .T.
.ActiveWorkbook.ActiveSheet.QueryTables.Add( oRS2, .Range("A1")).Refresh
Endwith
Erase 'disconnectme.rst'
------------------------------------
Thnx everybody for your support !!!!This afhternoon i found a workaround and its something like cetin proposed. instead of using export to type xls, i did copy to myfile.xls type fox2x. So all my table is in a fox2x format with an xls extension.
And Problem solved !!!
- Whoever said that women are the weaker sex never tried to wrest the bedclothes off one in the middle of the night
- Worry is the interest you pay, in advance, for a loan that you may never need to take out.
Previous
Reply
Map
View

Click here to load this message in the networking platform