Information générale
Catégorie:
COM/DCOM et OLE Automation
Titre:
Combining XLS files into one workbook
Versions des environnements
Network:
Windows 2000 Server
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
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement