Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Combining XLS files into one workbook
Message
De
26/07/2005 13:06:24
Scott Malinowski
Arizona Fox Software LLC
Arizona, États-Unis
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Titre:
Combining XLS files into one workbook
Versions des environnements
Visual FoxPro:
VFP 6 SP5
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
Visual FoxPro
Divers
Thread ID:
01035967
Message ID:
01035967
Vues:
64
Greetings!

I am trying to use low level file IO to combine three Excel spreadsheet files into one workbook, each occupying a different worksheet.

Here's the code I used to test this:
****************************************
*!* output file - already exists and is empty
fo4 = fopen('..\docs\1006 55 12 2004.xls', 1)

*!* First worksheet
fo2 = fopen('..\docs\az_file_2.xls', 0)
fs2 = fseek(fo2, 0, 2)
fr2 = fread(fo2, fs2)
fk2 = fseek(fo2, 0, 0)
fr2 = fread(fo2, fs2)
fw4 = fwrite(fo4, fr2)

*!* Second worksheet
fo1 = fopen('..\docs\az_file_1.xls', 0)
fs1 = fseek(fo1, 0, 2)
fr1 = fread(fo1, fs1)
fk1 = fseek(fo1, 0, 0)
fr1 = fread(fo1, fs1)
fw4 = fwrite(fo4, fr1)

*!* Third worksheet
fo3 = fopen('..\docs\az_file_3.xls', 0)
fs3 = fseek(fo3, 0, 2)
fr3 = fread(fo3, fs3)
fk3 = fseek(fo3, 0, 0)
fr3 = fread(fo3, fs3)
fw4 = fwrite(fo4, fr3)

*!* close the output file
? fclose(fo4)
****************************************
There are three input files, each with a different format, but all in excel file format and created using the VFP "COPY TO filename TYPE XL5" command.

Simply concatenating the files does not work. The data seems to concatenate ok, that is, the file size increases, but when you open the new XLS spreadsheet in Excel, only the first worksheet is there. Closing Excel truncates the XLS file back to the size of the first file that I concatenated.

Do I have to use Automation to combine these into one XLS file, but separate worksheets? Or, is there something I'm missing in the file IO process?

Thanks in advance!
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform