Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
COPY TO ... XL? for big tables
Message
 
To
18/12/2006 12:26:31
Howard Brown
Howard J. Brown Consulting Services Inc.
North Kingstown, Rhode Island, United States
General information
Forum:
Visual FoxPro
Category:
Troubleshooting
Environment versions
Visual FoxPro:
VFP 6 SP5
OS:
Windows 2000 SP4
Miscellaneous
Thread ID:
01178604
Message ID:
01178653
Views:
16
>copy to filename xls and
>copy to filename xl5
>both cut off the output at about 16k.
>
>can copy to command be used for a bigger input table (e.g. 25k records)?
>TIA
>Howie Brown

Brown
We use this function
CLOSE DATABASES ALL
USE c:\MyBigTable
SELECT 0
allIsOk = CopyToExcel("MyBigTable")
...
RETURN


FUNCTION CopyToExcel(MyTable)
LOCAL myExcelName

myExcelName = PutFile("Save as",m.MyTable,"XLS")

IF .NOT. EMPTY(m.myExcelName)
   IF FILE(m.myExcelName)
      m1 = FOPEN(m.myExcelName, 12)
      IF m1 > 0
         FCLOSE(m1)
      ELSE
         MESSAGEBOX("The file is open", 16, "Error")
         RETURN .f.
      ENDIF
   ENDIF

   SELECT (MyTable)

   GO TOP
***   Limit = 65534  &&& 65535 - 1 for VFP8 and VFP9
   m.Limit = 16383   &&& 16384 - 1 for VFP6

   broi_zapis = RECCOUNT()
   broi_zikli = CEILING(m.broi_zapis / m.Limit)
   expo_files = ""
   FOR zik = 1 to broi_zikli
       IF m.zik = 1
          name_part = myExcelName
       ELSE
          name_part = SUBSTR(m.myExcelName,1,rat(".",m.myExcelName)-1) + "_"+ALLTRIM(STR(m.zik-1,10,0))+".xls"
          SKIP
       ENDIF

       EXPORT TO (m.name_part) XL5 NEXT m.Limit

       expo_files = expo_files + IIF(EMPTY(expo_files),[],CHR(13))+ m.name_part
   NEXT
   MessageBox(m.expo_files, 64, "Export to")
ELSE 
   RETURN .f.
ENDIF
HTH
_______________________________________________________________
Testing displays the presence, not the absence of bugs.
If a software application has to be designed, it has to be designed correctly!
_______________________________________________________________
Vladimir Zografski
Systems Analyst
Previous
Reply
Map
View

Click here to load this message in the networking platform